0
votes

I have two different eventSources for displaying events in FullCalendar - One from Google Calendar and another from Local Database.

Here are my event sources:

eventSources: [
        {
            url: $('#google_calendar_xml').val(), //Get google calendar url from element value
            className: 'google-event'
        },

        {
            url: '/planner/events',
            className: 'local-event'
        }
]

Both the event sources are working and events are being rendered perfectly. However, if the same event is created in Google Calendar and Full Calendar, I need to display only one event. To achieve this, I need a way to compare all the events for their title, start and end time from both sources.

I searched the FullCalendar documentation but could not find any function or way to achieve this.

1

1 Answers

1
votes

You can use eventAfterAllRenderwhich is triggered after all events have finished rendering in the fullCalendar from both source.

eventAfterAllRender: function( view ) {
    var allevents = $('#calendar').fullCalendar('clientEvents');
}

Now, with the allevents object, you can do many.

Here is the one I took for me:

eventAfterAllRender: function(view) {
                    var allevents = $('#calendar').fullCalendar('clientEvents');
                    var countevents = 0;
                    if( allevents.length ) {
                        countevents = countevents + allevents.length;
                    }
                    if(!allevents) {
                        // alert('event count is'+countevents);
                        console.log('event count is',countevents);
                    }
                }