Jas*_*ams 3 jquery fullcalendar fullcalendar-4
我正在从 JSON 源加载动态事件,但是每次单击不同的房间时,我都想在获取新事件之前清除所有事件
我试图清除 eventSource 但无济于事
var eventSource = calendar.getEventSources()
eventSource.remove();
Run Code Online (Sandbox Code Playgroud)
这导致错误:
Uncaught TypeError: eventSource.remove is not a function
Run Code Online (Sandbox Code Playgroud)
我以前一直在使用 V3,但升级到 V4 并且文档有点难以理解如何清除事件。
你绝对是对的,我今天收拾东西特别慢!
var eventSources = calendar.getEventSources();
var len = eventSources.length;
for (var i = 0; i < len; i++) {
eventSources[i].remove();
}
Run Code Online (Sandbox Code Playgroud)
您可以调用removeAllEvents
函数删除所有事件而无需刷新整个页面:
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {/*OPTIONS*/});
$('#button').on('click', function () {
calendar.removeAllEvents();
});
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7191 次 |
最近记录: |