1

如果删除的事件是原始事件数组的一部分,为什么不能将它重新添加到 FullCalendar?

这有效(http://jsfiddle.net/fTu98/1/):

// A simple event object
e = {id: 1, title: 'a', start: Date.now()/1000 };

// Create calendar with no events
$("#calendar").fullCalendar({ events: [] });

// Add event to calendar
$("#calendar").fullCalendar('renderEvent', e);

// Remove event from the calendar
$("#calendar").fullCalendar('removeEvents', 1);

// Re-add event
$("#calendar").fullCalendar('renderEvent', e);

虽然这不是(http://jsfiddle.net/BNmrQ/2/):

// A simple event object
e = {id: 1, title: 'a', start: Date.now()/1000 };

// Create calendar with the event
$("#calendar").fullCalendar({ events: [e] });

// Remove event from the calendar
$("#calendar").fullCalendar('removeEvents', 1);

// Try re-adding event, doesn't work!
$("#calendar").fullCalendar('renderEvent', e);

我想通过说它“在日历上呈现一个新事件”来暗示这一点的文档renderEvent,但我不明白为什么会这样。

谢谢!

4

2 回答 2

1

this bug has been resolved in version 2.0.0 of FullCalendar: https://code.google.com/p/fullcalendar/issues/detail?id=1997

于 2014-06-24T06:00:09.250 回答
1

我没有“为什么”的答案,但我可以告诉你一个解决方法

如果您将事件对象复制到另一个对象中,它将起作用(使用新对象)

e2 = $.extend({}, e);

http://jsfiddle.net/BNmrQ/5/

于 2013-09-12T21:44:18.570 回答