1

我一直在尝试让 fullcalendar 对新事件的轮询做出反应,但是每当它调用 refetchEvents 时,如果我正在拖动或调整某些东西的大小,它就会阻止我,就好像我在我所在的位置释放了鼠标一样,它移动或将事件分别调整到错误的位置。

我有一个jsfiddle,以展示这一点。

这是代码,如果有帮助:

$(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);
4

1 回答 1

1

可能不是最有效的,仅在发布时使用和获取事件的fetchEventsLock引用。eventDragStarteventDragStop=== false

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);
于 2017-01-27T01:12:38.357 回答