I'm using FullCalendar as an interface for users to schedule appointments. When I load the calendar, I paint individual days based on the number of appointments already scheduled on that day. Here's the code:
function paintCalendar (dailyPercentage) {
$.each(dailyPercentage, function(){
if (this.percentage >= 65) {
$cell = $('td.fc-future[data-date="' + this.date.substring(0, 10) + '"]');
$cell.addClass('fc-high-traffic');
$calendar.fullCalendar('refetchEvents');
} else if (this['percentage'] >= 35) {
$cell = $('td.fc-future[data-date="' + this.date.substring(0, 10) + '"]');
$cell.addClass('fc-medium-traffic');
$calendar.fullCalendar('refetchEvents');
}
});
}
Each of the classes I add simply has a background-color associated with it.
However, when a user clicks the prev, next, or today buttons, the calendar is completely reloaded and my added classes are removed.
I saw a similar question here but his solution involved passing additional data in the event objects themselves. I'm dealing with the days themselves which aren't passed through.
Is there any way I can trigger an event after the calendar is refreshed similar to this response?
My function works just fine I just need an event to trigger its execution.