[英]How to add rel attribute to each event in FullCalendar?
I have this 我有这个
$('a.fc-event').each(function() { $(this).attr('rel', 'shadowbox'); });
after my FullCalendar code, and it works great for the initial page loaded of the calendar. 在我的FullCalendar代码之后,它对于日历的初始页面非常有用。 However when you switch to a different month or view, the rel attribute I set is then absent. 但是,当您切换到其他月份或视图时,则将缺少我设置的rel属性。 I need to render that rel="shadowbox" either from FC so it's loaded with every event link everywhere or re-set it again with every view change. 我需要从FC中渲染该rel =“ shadowbox”,以便将它随处都加载到每个事件链接中,或者在每次视图更改时都重新设置它。 How do I do this? 我该怎么做呢? Please help, thanks. 请帮忙,谢谢。
You should use the eventAfterAllRender
callback, this callback is called once an entire view + events has been rendered. 您应该使用eventAfterAllRender
回调,一旦渲染了整个视图+事件, eventAfterAllRender
调用此回调。 See here for more details. 有关更多详细信息,请参见此处 。
So your code will look something like: 因此,您的代码将类似于:
$('#calendar').fullCalendar({
//... whatever code you already have
eventAfterAllRender: function (view) {
//your code here
$('a.fc-event').each(function() {
$(this).attr('rel', 'shadowbox');
});
}
});
You could also look into the eventRender
callback ( see here ) if you want to do styling per event. 如果您想对每个事件进行样式设置,则还可以查看eventRender
回调( 请参见此处 )。 (but that is up to you). (但这取决于您)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.