zjwang zjwang - 7 months ago 34
Javascript Question

pickadate.js is not getting my pre populated date field

i'm using the pickadate.js library for selection of dates in my rails app. I have a page where the datefield is pre populated. On sumbit i expect the prepopulated values to be submitted however pickadate it will always submit a default date(current date)

Does anyone have experience working with the pickadate.js library? Does anyone know the correct way to let pickadate recognize my pre populated date value? Thanks in advance.

Here is my code,

Javascript showing pickadate settings, notice that I also used pickatime which works well with my prepopulated time value

$('#offer_valid_from_date').pickadate({format:'ddd, d mmm',formatSubmit:'ddd, d mmm',hiddenSuffix: '',});
$('#offer_valid_from_time').pickatime({min: [7,30], max: [24,0], formatLabel: 'h:i A',formatSubmit:'HH:i:00',hiddenSuffix: ''});


below shows the rendered html code of the inputs with pre populated date and time.

<input class="form-control" id="offer_valid_from_date" name="offer[valid_from_date]" type="text" value="Fri, 28 Feb" />
<input class="form-control" id="offer_valid_from_time" name="offer[valid_from_time]" type="text" value="8:00 AM" />

Answer

I've had problems with formatSubmit:'ddd, d mmm' in the past. Try removing that from your pickadate settings and see if it helps.

Comments