我有一个jQuery UI DatePicker日历alerts
当点击一个有事件的日期时。 http://jsfiddle.net/helpinspireme/DuwZL/我想添加的是加载,如果今天有一个事件,我希望在加载日历时显示警报。任何帮助将不胜感激。谢谢。
var events = [
{ Title: "Meeting with boss", Date: new Date("04/13/2012") },
{ Title: "Meeting with manager", Date: new Date("04/13/2012") },
{ Title: "Five K for charity", Date: new Date("04/17/2012") },
{ Title: "Dinner", Date: new Date("04/25/2012") }
];
$("div").datepicker({
beforeShowDay: function(date) {
var result = [true, '', null];
var matching = $.grep(events, function(event) {
return event.Date.valueOf() === date.valueOf();
});
if (matching.length) {
result = [true, 'highlight', null];
}
return result;
},
onSelect: function(dateText) {
var date,
selectedDate = new Date(dateText),
i = 0,
event = null;
while (i < events.length) {
date = events[i].Date;
if (selectedDate.valueOf() === date.valueOf()) {
event = events[i];
alert(event.Title);
}
i++;
}
}
});