以下代码针对 jQuery UI 日期选择器运行。根据 JSON 响应是否包含该日期的数据来突出显示日期。这在 Chrome (32.0.1675.2 canary) 中可以正常工作,但在 Firefox 中不行。有谁知道为什么会这样?FF 中没有添加高亮类。
function( response ) {
MyApp.events = response;
//console.log(events[1]);
$("#my-event-calendar" ).datepicker({
beforeShowDay: function(date) {
var result = [true, '', null];
var matching = $.grep(MyApp.events, function(event) {
//console.log(new Date(event.Date).valueOf() );
dateToHighlight = new Date(event.Date).valueOf();
return dateToHighlight === date.valueOf();
});
if (matching.length) {
result = [true, 'highlight', null];
}
return result;
},
在 Chrome 中,console.log(new Date(event.Date).valueOf() );
呈现,1380582000000
但在 Firefox 中,这是-1775005200000
更新,JSON数据现在格式如下:
对象{日期:“2013-10-02T14:30:00+00:00”,标题:“事件标题”}