[英]FullCalendar: How to recreate/reinitialize FullCalendar or batch add multiple events
我正在嘗試批量添加新事件到日歷,但未能找到一個方便的方法來使用。 所以我決定用新事件數組重新初始化視圖。 所以我嘗試了以下方法:
var events = [
{
title: 'Event',
start: new Date(y, m, d, 10),
description: 'long description',
id: 1
},
{
title: 'background',
start: new Date(y, m, d, 11),
end: new Date(y, m, d, 14),
description: 'long description',
id: 0,
color: "#00FF00",
textColor: "#000000",
placeholder: true,
}];
$('#calendar').fullCalendar({
events: events
});
$('#calendar').fullCalendar();
我仍然可以看到這些事件,這意味着第二次初始化調用實際上不起作用。 在這種情況下有什么工作嗎?
剛剛找到了一個散步......你可以做到
$('#calendar').fullCalendar({
events: events
});
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar();
摧毀它然后重新創造。
但是,我仍然不知道如何批量添加事件。
您可以像這樣使用addEventSource() :
.fullCalendar( 'addEventSource', events )
Source可以是Array / URL / Function,就像在events選項中一樣。 活動將立即從此來源獲取並放置在日歷上
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.