Recover all events using Fullcalendar

Asked

Viewed 130 times

1

I need to retrieve all events from my calendar and then recover every day that have an event.

I’ve already tried

$("#calendar").fullcalendar("getSource");

but Iss doesn’t work

1 answer

0

To capture all events, use:

// Obter array de eventos
var eventos = $('#calendar').fullCalendar('clientEvents');

This command will return an array of all events, and consequently within each event has a start date and an end date. You can scroll through this array and get all start dates of each event:

// Criar um array para armazenar os dias que tem evento
var dias = [];

// Percorrer array de eventos armazenando os dias que ainda não estão no array
eventos.forEach(function(evento){
    var data = evento.start._d;
    var dataString = data.getFullYear() + '-' + data.getMonth() + '-' + data.getDate();
    if(dias.indexOf(dataString) < 0){
        dias.push(dataString);
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.