2017-01-26 35 views
1

我一直在試圖讓fullcalendar對新事件的輪詢作出反應,但每當它調用refetchEvents,如果我拖動或調整某些東西,它會阻止我,就好像我在我所在的位置釋放了鼠標,這會將事件分別移動或調整到錯誤的位置。如何停止fullcalendar中斷拖動和調查時調整大小

我有一個jsfiddle,以顯示此操作。

下面是代碼,如果它可以幫助:發佈=== false

$(document).ready(function() { 

    /* initialize the calendar 
    -----------------------------------------------------------------*/ 

    $('#calendar').fullCalendar({ 
    header: { 
     left: 'prev,next today', 
     center: 'title', 
     right: 'month,agendaWeek,agendaDay' 
    }, 
    editable: true, 
    events: [{ 
     title: 'event1', 
     start: '2017-01-26T08:00:00', 
    end: '2017-01-26T10:00:00' 
    }, { 
     title: 'event2', 
     start: '2017-01-05', 
     end: '2017-01-07' 
    }, { 
     title: 'event3', 
     start: '2017-01-09T06:30:00', 
    end: '2017-01-09T09:30:00', 
    }] 
    }); 
}); 
setInterval(function() { 
    $('#calendar').fullCalendar('refetchEvents'); 
    console.log('refetchEvents called'); 
}, 5000); 

回答

1

可能不是最有效的,對eventDragStarteventDragStop使用fetchEventsLock參考,並獲取事件時。

var fetchEventsLock = false; 
$(document).ready(function() { 

    /* initialize the calendar 
    -----------------------------------------------------------------*/ 

    function toggleLock() { 
     fetchEventsLock = !fetchEventsLock; 
     console.log('Set To ' + fetchEventsLock) 
    } 
    $('#calendar').fullCalendar({   
     eventDragStart: toggleLock, 
     eventDragStop: toggleLock, 
     /* Other option removed */ 

    }); 
}); 
setInterval(function() { 
    if (fetchEventsLock === false) { 
     $('#calendar').fullCalendar('refetchEvents'); 
     console.log('refetchEvents called'); 
    } 
}, 5000); 
+1

對於我來說,這足夠好用,除了它需要eventResizeStart:toggleLock和eventResizeStop:toggleLock以及。 –

相關問題