我在wijmo.com网站上看的wijmo calendar插件的文档里面写的selectDate(date)的方法,但是在看custom selection的源码的时候,有点看不懂那段代码,有没有人能给我讲解一下。地址是:http://wijmo.com/demo/explore/?w ... =Custom%20selection 。
下面把源码贴出来
$(function () {
$("#calendar1").wijcalendar({
beforeSelect: function (e, data) {
var selDates = $("#calendar1").wijcalendar('option', 'selectedDates'), selected = false;
$.each(selDates, function (i, d) {
if (data.date.getFullYear() === d.getFullYear() &&
data.date.getMonth() === d.getMonth() &&
data.date.getDate() === d.getDate()) {
selected = true;
}
});
if (selected)
$("#calendar1").wijcalendar('unSelectDate', data.date);
else
$("#calendar1").wijcalendar('selectDate', data.date);
var list = $("#msg").empty()
selDates = $("#calendar1").wijcalendar('option', 'selectedDates');
$.each(selDates, function (i, d) {
var li = $("<li/>");
li.text(d.getFullYear() + "/" + (d.getMonth() + 1) + "/" + d.getDate());
list.append(li);
});
return false;
}
});
}); |
|