Is there a way to prevent overlapping events in jQuery FullCalendar?
Just add
eventOverlap: false
as one of your options outside of the events element.
You can also add the option
overlap
to a single event, which will override the eventOverlap on that single event.
events: [
{
title : 'event1',
start : '2017-05-27'
},
{
title : 'event2',
start : '2017-05-28',
end : '2017-05-29'
},
{
title : 'event3',
start : '2017-05-30T12:30:00',
allDay : false, // will make the time show
draggable: true,
editable: true,
overlap: true,
},
{
title : 'event3',
start : '2017-05-30T09:30:00',
allDay : false, // will make the time show
draggable: true,
editable: true,
}
],
eventOverlap: false
As of version 2.20 this change has been incorporated by default...
use
eventOverlap: false
http://fullcalendar.io/docs/event_ui/eventOverlap/
Same as Matthew Webb but Following worked for me since sometimes my end date was null when i was dragging the event from allDay to some time slot
function isOverlapping(event) {
var arrCalEvents = $('#' + g_str_FullCalenderID).fullCalendar('clientEvents');
for (i in arrCalEvents) {
if (arrCalEvents[i].id != event.id) {
if ((event.end >= arrCalEvents[i].start && event.start <= arrCalEvents[i].end) || (event.end == null && (event.start >= arrCalEvents[i].start && event.start <= arrCalEvents[i].end))) {//!(Date(arrCalEvents[i].start) >= Date(event.end) || Date(arrCalEvents[i].end) <= Date(event.start))
return true;
}
}
}
return false;
}
Same as ecruz's answer but with logic that worked better for me.
function isOverlapping(event){
// "calendar" on line below should ref the element on which fc has been called
var array = calendar.fullCalendar('clientEvents');
for(i in array){
if (event.end >= array[i].start && event.start <= array[i].end){
return true;
}
}
return false;
}
allowCalEventOverlap: [boolean | default: false] – Whether the calendar will allow events to overlap. Events will be moved or resized if necessary if they are dragged or resized to a location that overlaps another calendar event.
is that what you were looking for?
Try this:
$('#calendar').fullCalendar({slotEventOverlap : false});
As per the documentation.