Is it possible to limit a day to a single all day event in month view? 开发者_如何转开发This ideally would handle individual date selections, as well as date ranges.
There is most certainly a better way to do this, but this is what I was able to come up with for the time being. I'd like to be able to accomplish this without having to loop all of the events.
select: function (newEvent_start, newEvent_end, allDay) {
var okToAdd = true;
$('#calendar').fullCalendar('clientEvents', function (event) {
if ( (newEvent_start >= event.start && newEvent_end <= event.end) || // between
(newEvent_start <= event.start && newEvent_end >= event.start) || // starts before, ends during
(newEvent_start >= event.start && newEvent_start <= event.end && newEvent_end >= event.end) // starts during, ends after
)
okToAdd = false;
});
if (okToAdd) {
calendar.fullCalendar('renderEvent',
{
title: 'Title goes here',
start: newEvent_start,
end: newEvent_end,
allDay: allDay
},
true
);
}
calendar.fullCalendar('unselect');
}
精彩评论