完整日历:如何重新添加属于原始事件数组的事件



如果已删除的事件是原始事件数组的一部分,为什么无法将其重新添加到 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 的文档通过说它"在日历上呈现一个新事件"来暗示这一点,但我不明白为什么会这样。

谢谢!

此错误已在 FullCalendar 的 2.0.0 版本中得到解决:https://code.google.com/p/fullcalendar/issues/detail?id=1997

我没有"为什么"的答案,但我可以向您展示解决方法

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

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

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

相关内容

最新更新