Skip to content
Advertisement

fullcalendar do something when view change

I need to do something when view change. For example when from motnh go to agendaDay.

Didnt work anythink.any ideas?

viewRender:(function() {

                var lastViewName;
                return function(view) {

                    var view = $('#calendar').fullCalendar('getView');
                    alert('The new title of the view is ' + view.title);
                }
            }),

and

viewRender:(function(view) {
                var view = $('#calendar').fullCalendar('getView');
                alert('The new title of the view is ' + view.title);
            }),

Advertisement

Answer

Small error in the code. You want the function inside the () to return another function but it isn’t running. The correct form is:

(function() {
    return function(){...};
})(); //extra parentheses run the function

This is called a Self-Executing Anonymous Function.


Your code works when you do:
viewRender: (function () {
    var lastViewName;
    return function (view) {
        var view = $('#calendar').fullCalendar('getView');
        alert('The new title of the view is ' + view.title);
    }
})(),
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement