I need to do something when view change. For example when from motnh go to agendaDay.
Didnt work anythink.any ideas?
JavaScript
x
10
10
1
viewRender:(function() {
2
3
var lastViewName;
4
return function(view) {
5
6
var view = $('#calendar').fullCalendar('getView');
7
alert('The new title of the view is ' + view.title);
8
}
9
}),
10
and
JavaScript
1
5
1
viewRender:(function(view) {
2
var view = $('#calendar').fullCalendar('getView');
3
alert('The new title of the view is ' + view.title);
4
}),
5
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:
JavaScript
1
4
1
(function() {
2
return function(){ };
3
})(); //extra parentheses run the function
4
This is called a Self-Executing Anonymous Function.
Your code works when you do:
JavaScript
1
8
1
viewRender: (function () {
2
var lastViewName;
3
return function (view) {
4
var view = $('#calendar').fullCalendar('getView');
5
alert('The new title of the view is ' + view.title);
6
}
7
})(),
8