I\'m loading dynamic events from a JSON source, but each time I click a different room, I want to clear all the events prior to fetching the new ones
I have attempte
version 5.4.0
https://fullcalendar.io/docs/Event-remove
$('#calendar').fullCalendar('removeEvents');
You can call removeAllEvents function to delete all event without refreshing the whole page :
document.addEventListener('DOMContentLoaded', function () {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {/*OPTIONS*/});
$('#button').on('click', function () {
calendar.removeAllEvents();
});
});
version 5 does not support the "removeEvents" function. you can loop through the list of events and delete them one by onevar listeEvent = calendar.getEvents();listeEvent.forEach(event => { event.remove()});
You are absolutely spot on, I'm having a particularly slow day on picking things up!
var eventSources = calendar.getEventSources();
var len = eventSources.length;
for (var i = 0; i < len; i++) {
eventSources[i].remove();
}
Was the solution, as you suggested @ADyson