Reputation: 191
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);
}),
Upvotes: 10
Views: 20518
Reputation: 105
As noted by @Willow (thanks), accepted answer will not work in version 5x.
viewRender, eventAfterAllRender, datesRender are all obsolete and break in version 5. Below are some FullCalendar documentations I found listing breaking changes per release.
DatesSet is the property to be used. Screenshot from ver. 5 documentation:
Taking your code example, below works for me. In case it benefits someone else.
// version 5.11.0 based code
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
...
datesSet: function (dateInfo) {
var view = dateInfo.view;
alert('The new title of the view is ' + view.title);
},
...
});
calendar.render();
});
Upvotes: 6
Reputation: 1466
In FullCalendar 5 this seems to be datesSet
: https://fullcalendar.io/docs/datesSet
Upvotes: 13
Reputation: 21
Little late but try:
eventAfterAllRender: (function (view) {
// your code
}),
Upvotes: 1
Reputation: 14133
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.
viewRender: (function () {
var lastViewName;
return function (view) {
var view = $('#calendar').fullCalendar('getView');
alert('The new title of the view is ' + view.title);
}
})(),
Upvotes: 3