I'm using the JQuery UI Datepicker to pick date. I set "changeMonth" and "changeYear" to true at the initialization.
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd',
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd',
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
But I want the datepicker to be set by default, so I used setDate BEFORE THE SETTING of changeMonth and changeYear:
$(#from).datepicker('setDate', '10-10-2010');
$(#to).datepicker('setDate', '10-10-2011');
This was successful. However, in the dropdown calendar on the header I could no longer directly change month and year.
Does anyone know what's happened or know the solution to this? Or I should rather change another way to set Date?
Thanks in advance for your help!