FullCalendar: how to recreate / reinitialize FullCalendar or batch add multiple events

I'm trying to add new events to my calendar, but couldn't find a convenient method to use. So I decided to just reinitialize the view with a new array of events. So I tried the following:

var events = [
    {
        title: 'Event',
        start: new Date(y, m, d, 10),
        description: 'long description',
        id: 1
    },
    {
        title: 'background',
        start: new Date(y, m, d, 11),
        end: new Date(y, m, d, 14),
        description: 'long description',
        id: 0,
        color: "#00FF00",
        textColor: "#000000",
        placeholder: true,
    }];
$('#calendar').fullCalendar({
    events: events
});
$('#calendar').fullCalendar();

      

I can still see these events, which means that the second initialization call doesn't actually work. Is there any work in this case?

+3


source to share


2 answers


You can use addEventSource () like so:

.fullCalendar( 'addEventSource', events )

      



The source can be Array / URL / Function, just like the events option. Events will be immediately retrieved from this source and placed on the calendar

+3


source


Just found a walkaround .. you could do

$('#calendar').fullCalendar({
    events: events
});
$('#calendar').fullCalendar('destroy');
$('#calendar').fullCalendar();

      



to destroy it and then recreate it.

But still, I don't know how to do batch event additions.

+5


source







All Articles