Datepicker + beforeShowDay + onChangeMonthYear + ajax get
Hi, I tried almost all but I cannot get this to work.
The situation is that I have an inline datepicker.
On the right of it, I print a list of events recurring during the
selected month/year, and the days are highlighted using the
beforeShowDay feature.
When the user change month, the onChangeMonthYear function is called
that it's supposed to get via ajax a new list of events for the newly
selected month and a new list (eg "[1,5,...,28]") of specialDays to be
used in beforeShowDay.
I cant get this to work, here is the onChangeMonthYear function, that
I think should be modified:
$("#calendar").datepicker({
// ...
onChangeMonthYear: function(year, month, inst) {
$.get("http://www.example.org/ajax/"+year+"/"+month, { }, function
(json) {
specialDays = json.specialDays; // array [1,5,...,20]
$(inst).datepicker("refresh");
},"json");
},
beforeShowDay: onBeforeShowDay
// ...
});
The onBeforeShowDay is straightforward and it works only when the page
first load:
var specialDays = [1,2,3];
function onBeforeShowDay(thedate)
{
var theday = thedate.getDate();
if( $.inArray(theday,specialDays) == -1 ) return [false,""];
return [true, "specialDate", "tooltip"];
}
What it happens is that the months change but special Days are not
highlighted :(