Jquery – Setting Fullcalendar Cell Background Color

background-colorcsseventsfullcalendarjquery

I saw several topics on how to set the background color of a cell in fullcalendar, but none of them worked for me. I guess the calendar used to list the days using their date as such .fc-day5 or .fc-day17, but in version 1.6.2 it doesn't anymore.

I have a list of several events that are being rendered and I want to set their cell color (the entire day cell, not only the event cell) to a specific color.

I use 'eventRender' to try to set a class

eventRender: function (event, element, monthView) { 
                if (event.className == "holiday") {
                    $day = $date.getDate();
                    $("td.fc-day-number[value='" + $day + "']").addClass("holiday");
                }
            },

Let me know if you have any idea on how to set the background color.

Best Answer

You can try to set event background color. Something like this:

event.backgroundColor = 'cccccc#';

Or for cell background:

$('.fc-day[data-date="' + date + '"]').css('background', color);

date must be date string equivalent to php Y-m-d date format. Style need change when calendar was rendered.

Related Topic