Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set events in fullcalendar from array

I'm using fullcalendar, but I want to set events from array, for example:

var countries = new Array();
countries[0] = {'title':'España', 'start':new Date(y, m, d+4, 19, 0), url:'http://google.com/'};
countries[1] = {'title':'Portugal', 'start':new Date(y, m, 22, 22, 0)};

This is a static example, I'll get this array and in each case I'd have 3 or 9 or ... differents events.

But example is:

$('#calendar').fullCalendar({
    editable: false,
    events: [ 
        {
            title: 'example',
            start: new Date(y, m, d+1, 19, 0),
            end: new Date(y, m, d+1, 22, 30),
            allDay: false
        },
        {
            title: 'Click for Google',
            start: new Date(y, m, 28),
            end: new Date(y, m, 29),
            url: 'http://google.com/'
        },         
    ]
});

How can I remove this two example events and set only my array "countries"?

Is it possible?

like image 768
user3396420 Avatar asked Dec 12 '22 05:12

user3396420


1 Answers

Removes events from the calendar.

$("#calendar").fullCalendar( 'removeEvents' [, idOrFilter ] )

Dynamically adds an event source.

$("#calendar").fullCalendar( 'addEventSource', source )

From here: https://fullcalendar.io/docs/addEventSource

like image 60
Kahosk Avatar answered Dec 21 '22 00:12

Kahosk