the Forum

Removing all eventSources in jQuery FullCalendar plugin

Posted on June 14, 2011 by Michael Rosario
Total Posts: 33  |  Join date: 03-12-11

I'm trying to remove all the event sources in the fullcalendar plugin. I'm currently using a combination of
removeEvents (method)
removeEventSource (method)
addEventSource (method
I was hoping there is a .replaceEventSource(), wishful thinking. Here is my current code:
$('#Calendar')
.
fullCalendar('removeEvents'//Hide all events
.fullCalendar'removeEventSource',$('.Source').val()) //remove eventSource from stored hidden input
.fullCalendar'addEventSource'newSource); //Add a new source 
It's just a matter of time. Any help would be nice.

Tags: There are no tags for this entry.

3 answers, add yours below

Posted on on June 15, 2011 at 1:28am
by Michael Rosario

So I was able to implement the solution found at:
http://code.google.com/p/fullcalendar/issues/detail?id=678

Modifying fullcalendar.js gives us the function removeEventSources() to remove all sources. I used a code to check if the source is empty before adding a new source. Then I use the the refetch command to avoid the duplicating issue when you click on a button multiple times. My only concern is that it takes a second to load the events.

MY CODE:
$('#Calendar').fullCalendar'removeEvents').fullCalendar('removeEventSources');  //Removes all event sources

if($('#Calendar').fullCalendar'clientEvents') == ""{  $('#Calendar').fullCalendar'addEventSource'newsource); // load the new source if the Calendar is empty

$('#Calendar').fullCalendar('refetchEvents');
//load the eventSource which is always one event source 


 

Posted on on October 2, 2011 at 2:04pm
by Taimi

Thanks alot - your answer solved all my problems after sevreal days struggling

 

Posted on on February 11, 2015 at 8:30am
by Eduardo

var calendar = $('#Calendar');

// Clear all events
calendar.fullCalendar( 'removeEvents', function(e){
return true;
});

// Renew event sources
calendar.fullCalendar('addEventSource', _events);

 
add your answers here
comments powered by Disqus