如何在FullCalendar中为每个事件添加rel属性?

时间:2015-11-04 14:06:07

标签: javascript jquery fullcalendar

我有这个



$('a.fc-event').each(function() {
   $(this).attr('rel', 'shadowbox');
});




在我的FullCalendar代码之后,它适用于日历加载的初始页面。但是,当您切换到其他月份或视图时,我设置的rel属性将不存在。我需要渲染rel =" shadowbox"要么来自FC,要么它随处可见每个事件链接,或者每次更改视图时重新设置它。我该怎么做呢?请帮助,谢谢。

1 个答案:

答案 0 :(得分:0)

您应该使用eventAfterAllRender回调,一旦渲染了整个视图+事件,就会调用此回调。有关详细信息,请参阅here

所以你的代码看起来像是:

$('#calendar').fullCalendar({
    //... whatever code you already have
    eventAfterAllRender: function (view) {
        //your code here
        $('a.fc-event').each(function() {
            $(this).attr('rel', 'shadowbox');
        });
    }
});

如果您想为每个活动设置样式,您还可以查看eventRender回调(see here)。 (但这取决于你)。