Set events in fullcalendar from an array

I use fullcalendar, but I want to set events from an 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 will get this array, and in each case I will have 3 or 9 or ... differents events.

But an example:

$('#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 these two example events and set only my array of "country"?

Is it possible? Thanks in advance.

+4
source share
1 answer

Deletes events from the calendar.

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

Dynamically adds an event source.

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

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

+7
source

Source: https://habr.com/ru/post/1542052/


All Articles