Any way to colorize specific days in FullCalendar?

user303615 picture user303615 · Mar 28, 2010 · Viewed 15.7k times · Source

Using FullCalendar, is there any way I can programmatically colorize specific days differently than the rest of the days? For example, in the "month" or "week" views, I'd like to colorize days with no events on them "red", and days with some events (but not yet a full schedule) "yellow". Days with a full schedule would be colorized normally (white background). Are there any callbacks or CSS tags I can take advantage of to add this behavior? Thank you.

Answer

pedromendessk picture pedromendessk · Jan 29, 2015

According to Regin's answer here you can change the color by setting the dayRender event in the calendar like this:

$( "#calendar" ).fullCalendar(function() {  
    dayRender: function (date, cell) {

        if ( !dateHasEvent(date) )
            cell.css("background-color", "red");
        else if ( dateHasEvent(date) )
            cell.css("background-color", "yellow");
    }
});

function dateHasEvent(date) {
   // some code here
}