JQuery UI Datepicker を使用して日付を選択しています。初期化時に「changeMonth」と「changeYear」をtrueに設定しています。
$( "#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 );
}
});
しかし、日付ピッカーをデフォルトで設定したいので、changeMonth と changeYear の設定の前に setDate を使用しました。
$(#from).datepicker('setDate', '10-10-2010');
$(#to).datepicker('setDate', '10-10-2011');
これは成功しました。ただし、ヘッダーのドロップダウン カレンダーでは、月と年を直接変更できなくなりました。
何が起こったのか、またはこれに対する解決策を知っている人はいますか?または、日付を設定する別の方法を変更する必要がありますか?
よろしくお願いします。