Fullcalendar - remove many events

215 Views Asked by At

I have a fullcalendar. In my fullcalendar, I have events with an id like 030820201013-trs. Other events do not have an id that ends in 'trs'.

I would like to remove events with id that ends in 'trs'. By doing:

$ ("# calendar"). FullCalendar (' removeEvents ', [' 030820201003-trs '])

, it works. However, if I do:

$ ("# calendar"). FullCalendar (' removeEvents ', [' 030820201003-trs ',' 030820201005-trs '])

, it doesn't work.

Would you be why? And how can I delete all the events without having to loop? (Which is long enough)

1

There are 1 best solutions below

3
On BEST ANSWER

Events in FullCalendar are stored as an array so there isn't really a way to remove events without having to loop through them.

You can however pass in a callback filter function to the removeEvents event to filter through all of events and remove the ones that end with trs. This function has The Event Object passed in which you can get the id from.

$("# calendar").FullCalendar(' removeEvents ', ({ id }) => id.endsWith('trs'))