rem
rem

Reputation: 161

How to reload jQuery FullCalendar with data from another event source?

I am using the FullCalendar jQuery plugin and trying to load events from a different source at the click of a custom button.

The calendar is correctly initialized with the results returned from the FIRST_REQUEST url, but when the custom button is clicked, the calendar does not get reloaded with the json data from the SECOND_REQUEST url.

Here is my code:

$('#calendar').fullCalendar({
    'locale'        : 'fr',
    'customButtons' : {
        myCustomButton: {
            text: global.labelAllEvents,
            click: function() {
                $('#calendar').fullCalendar( 'refetchEventSources', {
                    url: '../url/SECOND_REQUEST'
                });
            }
        }
    },
    'header' : {
        left:   'prev,next today myCustomButton',
        center: 'title',
        right:  'month,agendaWeek,agendaDay,listMonth'
    },
    'defaultView'   : window.mobilecheck() ? "basicDay" : "month",
    'firstDay'      : 1,
    'eventLimit'    : true,
    'events'        : '../url/FIRST_REQUEST?code='+parent.codeLiveroom ,
    'eventColor'    : 'lightBlue',
    'eventTextColor': 'black',
    'editable'      : true,
    'selectable'    : true,
    'longPressDelay': 500,
    'timeFormat'    : 'H:mm'
});

Thanks in advance.

Remi

Upvotes: 1

Views: 3245

Answers (1)

MVG1984
MVG1984

Reputation: 645

May be something like that?

var events = {
        url: "../url/SECOND_REQUEST",
        type: 'POST',
        data: {}
    }

    $('#calendar').fullCalendar( 'removeEventSource', events);
    $('#calendar').fullCalendar( 'addEventSource', events);         
    $('#calendar').fullCalendar( 'refetchEvents' );

Upvotes: 2

Related Questions