FullCalendar - Highlight a particular day in week view

懵懂的女人 提交于 2019-12-06 00:15:54

Ok Guys, I worked out a solution for my problem.

Following this documentation on the FullCalendar site, I used the callback method dayRender() to solve my problem.

The above method has two parameters- date and cell. The first one stores all the days of a week in basicWeek view. So, given my required date is stored in a variable reqDate, I did something like this:

$('#my-div').fullCalendar({
    year: reqDate.getFullYear(),
    month: reqDate.getMonth(),
    date: reqDate.getDate(),
    dayRender: function(daysOfWeek, cell)
    {
        if(reqDate.getDate()==daysOfWeek.getDate())
        {
            $(cell).addClass('fc-state-highlight');
        }
        else
        {
            $(cell).removeClass('fc-state-highlight');
        }
    }
});

That's it :)

You can create new event during onload and prev and next button.

The function should check for the current week like,

$( "table.fc-agenda-days" ).hasClass( "td.fc-today" )

or

if ($("table.fc-agenda-days").find("td.fc-today").length > 0){ 
    $("table.fc-agenda-days td.fc-widget-content").addClass('fc-state-highlight');
}

Hope, this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!