【发布时间】:2014-04-30 15:50:01
【问题描述】:
我使用 FullCalendar 作为用户安排约会的界面。当我加载日历时,我会根据当天已经安排的约会数量来绘制各个日期。代码如下:
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');
}
});
}
我添加的每个类都有一个与之关联的背景颜色。
但是,当用户单击上一个、下一个或今天按钮时,日历会完全重新加载,并且我添加的课程会被删除。
我看到了一个类似的问题here,但他的解决方案涉及在事件对象本身中传递额外的数据。我正在处理那些没有经历过的日子。
有什么方法可以在日历刷新后触发事件,类似于this response?
我的函数工作得很好,我只需要一个事件来触发它的执行。
【问题讨论】:
标签: jquery fullcalendar repaint