Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup default date for jQuery inline datePicker?

I'm using this jQuery inline datePicker plugin sample but I don't know how to set up default date selected. Do you have any idea?

like image 928
dole doug Avatar asked Apr 05 '09 08:04

dole doug


2 Answers

$('.date-pick').datePicker({
    defaultDate: $.datepicker.parseDate("d m y", "31 8 2009")
})
like image 60
Philippe Rathé Avatar answered Nov 26 '22 20:11

Philippe Rathé


You will need to use the dpSetSelected method . I've added that into the code from the example page below:

$(function()
{
    $('.turn-me-into-datepicker')
        .datePicker({inline:true})
        .dpSetSelected('01/04/2010') // The string should be in Date.format
        .bind(
            'dateSelected',
            function(e, selectedDate, $td)
            {
                console.log('You selected ' + selectedDate);
            }
        );
});

As mentioned, if you have changed Date.format then you will need to ensure that the string is in the format you changed it to.

like image 25
vitch Avatar answered Nov 26 '22 19:11

vitch