I have a pretty simple code involving the jQuery UI datepicker:
$('.date-picker').datepicker({
dateFormat: 'MM yy',
changeMonth: true,
changeYear: true,
showButtonPanel: true,
})
.change(function() {
var date = $(this).datepicker('getDate');
$('#dateShow').val(date);
});
The problem is that in the change handler I always get the today date, not the one I've picked in the calendar, every time I select another month or year. Here is jsFiddle.
Does anybody have an idea of what I'm doing wrong? How could such a basic use case lead datepicker's getDate to return an incorrect value?
UPDATE: The code sample is simplified and question is reformulated accordingly.