我最近正在研究 FullCalendar 。正在关注this thread从页面上的日期选择器中选择后,我可以转到特定日期。
我正在周 View 中显示 FullCalendar。我的问题是,在周 View 中,我无法在我去过的日期应用 fc-state-highlight
类。尽管本周有我要求的日期,但它从未突出显示。
但是,我可以使用以下方法从当前日期删除相同的类(class)
$('.fc-today').removeClass('fc-state-highlight');
我需要将上述类(class)添加到我的最新类(class)中。
任何帮助将不胜感激。
编辑:我自己发布了解决方案。
最佳答案
好的,大家,我已经找到了解决问题的方法。
已关注 this documentation在 FullCalendar 站点上,我使用回调方法 dayRender()
来解决我的问题。
上述方法有两个参数 - date
和 cell
。第一个在 basicWeek
View 中存储一周中的所有日子。因此,考虑到我所需的日期存储在变量 reqDate
中,我做了如下操作:
$('#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');
}
}
});
就是这样:)
关于jquery - FullCalendar - 在周 View 中突出显示特定的一天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19783833/