$('.selector').datepicker({ onChangeMonthYear: function(year, month, inst) { ... } });
How can I use the "inst" onChangeMonthYear parameter to automatically select the first day of the month?
see http://jsfiddle.net/sD8rL/
I am currently using the code below, but it seems to me that I can use the "inst" variable in a more direct way.
$(".datepicker" ).datepicker({ changeMonth: true, changeYear: true, maxDate:0, onChangeMonthYear: function(year, month, inst){ // set date to 1st on year or month change // this seems bit janky, but works $('#' + inst.id).datepicker( "setDate", month + '/1/' + year ); // Can't I use the instatnce to set the date? // $(inst).datepicker( "setDate", month + '/1/' + year ); // fails // inst.datepicker( "setDate", month + '/1/' + year ); // fails // inst.selectedDay = 1; // fails // inst.currentDay = 1; // fails } });
Actionowl
source share