避免出现错误,fullcalendar 需要的属性要写 ,下面是部分代码
events:
/*
function(start,end,callback){
//alert($.fullCalendar.formatDate(start,'yyyy-MM-dd'));
//alert($.fullCalendar.formatDate(end,'yyyy-MM-dd'));
var params = {start:$.fullCalendar.formatDate(start,'yyyy-MM-dd'),end:$.fullCalendar.formatDate(end,'yyyy-MM-dd'),empSn:'{{_USER_.name}}'};
$.ajax({
url:"/main/event/getEventList",
type:"post",
data:params,
dataType: 'json',
success: function(res){
//var jsontext = [{ id: 1, title: 'studyjQuerypost', start: '2015-09-01 08:00', end: '2015-09-01 10:30',allDay:0 },{ id: 2, title: 'studyjQuerypost3', start: '2015-09-02', end: '2015-09-02',color:'red' }];
callback(res);
},
error:function(error){
alert("服务器错误!");
}
});
// checkPlan(start,end);
},*/
[
{
title: 'All Day Event',
start: '2017-04-01',
end:'2017-04-07',
allDay:true,
editable:false,
textColor:'red',
color:'green'
},
{
title: 'Long Event',
start: '2017-04-07',
end: '2017-04-10'
}]
重要的来了具体实现
dayClick: function(date, jsEvent, view) {
var events = $('#calendar').fullCalendar('clientEvents', function(event) {
var eventStart = event.start.format('YYYY-MM-DD');
var eventEnd = event.end ? event.end.format('YYYY-MM-DD') : null;
var theDate = date.format('YYYY-MM-DD');
// Make sure the event starts on or before date and ends afterward
// Events that have no end date specified (null) end that day, so check if start = date
return (eventStart <= theDate && (eventEnd >= theDate) && !(eventStart < theDate && (eventEnd == theDate))) || (eventStart == theDate && (eventEnd === null));
});
console.log(events); // do whatever with the console.log(events[0]._allDay);
}