Is there a way to prevent overlapping events in jQuery FullCalendar?

前端 未结 10 2069
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 03:47

Is there a way to prevent overlapping events in jQuery FullCalendar?

相关标签:
10条回答
  • 2020-12-01 04:07

    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
    
    0 讨论(0)
  • 2020-12-01 04:11

    As of version 2.20 this change has been incorporated by default...

    use

    eventOverlap: false

    http://fullcalendar.io/docs/event_ui/eventOverlap/

    0 讨论(0)
  • 2020-12-01 04:11

    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;
    }
    
    0 讨论(0)
  • 2020-12-01 04:15

    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;
    }
    
    0 讨论(0)
  • 2020-12-01 04:19

    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?

    0 讨论(0)
  • 2020-12-01 04:21

    Try this:

    $('#calendar').fullCalendar({slotEventOverlap : false});

    As per the documentation.

    0 讨论(0)
提交回复
热议问题