我想在单击按钮时删除fullcalendar v5中的所有事件,下面的代码可以正常工作
calendar.addEventSource([
{
title: 'Business Lunch',
start: '2020-04-03T01:00:00',
},
]);
但是在单击按钮后如何删除/清除/删除所有事件? Fullcalendar的旧版本具有此方法
calendar.fullCalendar( 'removeEvents', []);
v5怎么样?我尝试了下面的代码,但它给了我一个错误remove is not a function
。我什至尝试了calendar.refetchEvents();
,但没有任何效果。
$('.button').click(function(event) {
calendar.remove();
});
答案 0 :(得分:3)
Fullcalendar v5 删除所有事件
calendar.removeAllEvents();
答案 1 :(得分:2)
必须在事件源实例上调用。使用getEventSources。
removeEvents = calendar.getEventSources();
removeEvents.forEach(event => {
event.remove();
});