problem with jQuery datepicker
Hi!
Please help me with one thing. I'm using jquery UI datepicker on my page in this way:
-
var list = {};
function getEventsDatesList() {
// fill list with dates to be display in calendar
...
list[new Date(date[2], date[0] - 1, date[1])] = true;
}
$j(document).ready(function() {
getEventsDatesList();
var lblMonthName = $j("#lblMonthName");
var arrMonthNames = ['....']; //monthes names
$j("#calendar").datepicker({
changeMonth: false,
changeYear: false,
minDate: new Date(2009, 4 - 1, 1),
maxDate: new Date(2009, 12 - 1, 31),
onSelect: function(dateText) {
window.location = "Restaurants-List.aspx?date=" + (dateText.replace('.', '-').replace('.', '-'));
},
beforeShowDay: function(date) {
//console.log([date, list[date]]);
return [list[date], 'event'];
},
onChangeMonthYear: function(year, month, inst) {
lblMonthName.html(arrMonthNames[month - 1]);
},
monthNames: arrMonthNames,
dateFormat: 'dd.mm.yy',
firstDay: 1
});
});
I'm using beforeShowDay event to make enabled only dates which are in the list variable;
But this not works on the page load. When I change monthes in the datepicker it begins to work fine. Why it doesn't work on the first load?
Thanks in advance!