I have the following code:
$.ajax({
url: 'my_url',
type: 'GET'
}).done(function(data){
availableDates = data;
var min = availableDates[0].split('-');
var max = availableDates[availableDates.length - 1].split('-');
var minDate = new Date(min[0], min[1] - 1, min[2]);
var maxDate = new Date(max[0], max[1] -1, max[2]);
$('#id_date').datepicker({
beforeShowDay: available,
minDate: minDate,
maxDate: maxDate,
});
}).fail(function(){
console.log('some message');
});
It sets the minDate, maxDate and the available dates. All that works fine on the first go. After making the AJAX call again, I get different dates so I have to change the minDate and the maxDate.
The maxDate changes as expected, but the minDate changes only if the new minDate is later than the original minDate. It won't change to a day in the past in regards to the previous minDate.
Any ideas?
Why are your re-initializing the date picker instead do following:
$( "#id_date" ).datepicker( "option", "minDate", minDate );
$( "#id_date" ).datepicker( "option", "maxDate", maxDate );