Reputation: 715
I've eventRender function to change day background for specific classname.
eventRender: function (event, element, view) {
if (event.className == 'booked') {
var dateString = $.fullCalendar.formatDate(event.start, 'yyyy-MM-dd');
view.element.find('.fc-day[data-date="' + dateString + '"]').css('background-color', '#FAA732');
}
},
This function working properly on fullcalendar 1.6.4 but not in version 2.1 (I already change date conversion to moment).
Uncaught TypeError: Cannot read property 'find' of undefined fullcalendar
Another problem is, this function only change the background of event start, not the whole date of an event
Upvotes: 0
Views: 1669
Reputation: 14980
$.fullCalendar.formatDate(event.start, 'yyyy-MM-dd');
Is no longer needed and doesn't work in 2.*. This is because event.start
is already a momentjs
object. You can simply use
event.start.format("YYYY-MM-DD");
As for view.element
, it was replaced by view.el[0]
, so you should use
$(view.el[0]).find('.fc-day[data-date=' + dateString + ']')
to change the specific day.
Your eventRender
will become
eventRender: function(event, element, view) {
var dateString = event.start.format("YYYY-MM-DD");
$(view.el[0]).find('.fc-day[data-date=' + dateString + ']')
.css('background-color', '#FAA732');
},
For the complete code check the JSFiddle demo.
Upvotes: 2