nik*_*kko 3 javascript fullcalendar fullcalendar-5
我想在单击按钮后删除 fullcalendar v5 中的所有事件,下面的代码工作正常
calendar.addEventSource([
{
title: 'Business Lunch',
start: '2020-04-03T01:00:00',
},
]);
Run Code Online (Sandbox Code Playgroud)
但是,单击按钮后如何删除/清除/删除所有事件?老版本的fullcalendar有这个方法
calendar.fullCalendar( 'removeEvents', []);
Run Code Online (Sandbox Code Playgroud)
v5 怎么样?我尝试了下面的代码,但它给了我一个错误remove is not a function。我什至尝试过calendar.refetchEvents();,但没有任何效果。
$('.button').click(function(event) {
calendar.remove();
});
Run Code Online (Sandbox Code Playgroud)
小智 5
必须在事件源实例上调用。使用 getEventSources。
removeEvents = calendar.getEventSources();
removeEvents.forEach(event => {
event.remove();
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7779 次 |
| 最近记录: |