FullCalendar - 在周视图中突出显示特定日期 [英] FullCalendar - Highlight a particular day in week view
问题描述
我现在正在 FullCalendar 上工作。按照此线程我可以在从我的页面上的日期选择器中选择特定日期。
我在周视图中显示FullCalendar。我的问题是,在周视图中,我无法在我去的日期应用 fc-state-highlight
类。即使这一周有我的要求的日期,它永远不会突出显示。
但是,我可以使用
$从当前日期中删除相同的类b$ b
$('。fc-today')。removeClass('fc-state-highlight');
我需要将上面的类添加到我的更新中。
任何帮助将不胜感激。
编辑:我自己发布了解决方案。
好的伙计们,我为我的问题找到了解决方案。
FullCalendar网站上的这个文档,我使用了回调方法 dayRender()
来解决我的问题。
以上方法有两个参数 - date
和 cell
。第一个存储一周的所有日子,在 basicweek
视图中。所以,由于我所需的日期存储在一个变量 reqDate
中,我做了这样的事情:
fullCalendar({
year:reqDate.getFullYear(),
month:reqDate.getMonth(),
date:reqDate($#$ my $) .getDate(),
dayRender:function(daysOfWeek,cell)
{
if(reqDate.getDate()== daysOfWeek.getDate())
{
$(cell).addClass('fc-state-highlight');
}
else
{
$(cell).removeClass('fc-state-highlight') ;
}
}
});
就是这样:)
I am newly working on FullCalendar. Following this thread I am able to go to a specific date when selected from a datepicker on my page.
I am displaying FullCalendar in week view. My problem here is, in week view I am not able to apply the fc-state-highlight
class on the date I have gone to. Even though the week has my required date, it is never highlighted.
However, I am able to remove the same class from the current date by using
$('.fc-today').removeClass('fc-state-highlight');
I need to add the above class to my gone-to-date.
Any help would be greatly appreciated.
EDIT: I have posted the solution myself.
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 :)
这篇关于FullCalendar - 在周视图中突出显示特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!