我见过很多关于“JavaScript 仅在警报下工作”的问题,但答案仅针对这些问题。我正在使用 Kendo Calender,并希望从数据库中的值中突出显示特定日期。以下代码仅在编写警报时才能正常工作。请帮助:
var duedates = [];
function GetDueDates() {
$.ajax({
type: "POST",
url: "ChartBinder.asmx/GetDueDates",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
duedates = $.parseJSON(msg.d);
},
error: function (msg) {
alert("error");
}
});
}
$(document).ready(function () {
GetDueDates();
//在这里插入警报时功能起作用..
var today = new Date();
$("#calendar").kendoCalendar({
change: onChange,
navigate: onNavigate,
value: today,
dates: duedates,
month: {
// template for dates in month view
content: '# if ($.inArray(+data.date, data.dates) != -1) { #' +
'<div class="' +
"dataexist" +
'"></div>' +
'# } #' +
'#= data.value #'
},
footer: "Today - #=kendo.toString(data, 'd') #"
});
$(document).find("#panelbar").kendoPanelBar({
expandMode: "single"
});
});