我想在 fullcalendar 中更新我的 json,这就是我正在尝试做的事情。 我有一个 JSON 字符串,我正尝试将其直接输入到完整日历中的事件对象中。
-->
var JSON[
{
"id": "1", // Optional
"title": "Demo event", // Required
"start": "2013-08-28 10:20:00", // Required
"end": "2013-08-28 11:00:00", // Optional
"allDay": false, // Optional
"url": "http://google.com", // Optional, will not open because of browser-iframe security issues
"className": "test-class", // Optional
"editable": true, // Optional
"color": "yellow", // Optional
"borderColor": "red", // Optional
"backgroundColor": "yellow", // Optional
"textColor": "green" // Optional
},
{
"id": "2", // Optional
"title": "Demo event 2", // Required
"start": "2013-08-27 10:20:00", // Required
"end": "2013-08-27 11:00:00", // Optional
"allDay": false, // Optional
"url": "http://google.com", // Optional, will not open because of browser-iframe security issues
"className": "test-class", // Optional
"editable": true, // Optional
"color": "yellow", // Optional
"borderColor": "red", // Optional
"backgroundColor": "yellow", // Optional
"textColor": "green" // Optional
}
];
,
然后我想将某些下拉事件(未在 fiddle 中显示)上的 JSON 修改为新字符串,并尝试在日历上获取新事件。
fullCalendar 不生效。
http://jsfiddle.net/pratik24/u8Ksw/28/
感谢您的帮助。欣赏它。
最佳答案
您没有调用正确的 fullCalendar 方法来呈现新事件。
这不起作用,因为它只是为了第一次渲染事件:
$("#demo-calendar").fullCalendar('renderEvents', JSON);
相反,您需要删除日历上的事件并刷新它们:
$("#demo-calendar").fullCalendar('removeEvents');
$("#demo-calendar").fullCalendar('addEventSource', JSON);
检查 fiddle :http://jsfiddle.net/shaunp/u8Ksw/29/
注意,有一个名为 refetchEvents
的 fullCalendar 方法,但它不适用于事件数组(例如您创建的事件),因此您必须手动获取事件关闭并再次重新添加事件源。
关于jquery - 如何更新 fullCalendar 中的事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18498079/