jquery完整日历:回调'在'日历已完全加载

jquery Full Calendar: callback 'after' the calendar has loaded completely

本文关键字:日历 加载 jquery 回调      更新时间:2023-09-26

Adam Shaw的jquery完整日历中是否有回调,该回调是在日历完全呈现后调用的??我想在回调中调用clientEvents函数,以获取客户端上的所有事件。我尝试在viewDisplay中执行此操作,但它在事件呈现之前被调用,并且clientEvents返回0个事件。

我知道这篇文章现在已经很旧了,但如果有任何帮助的话,你不需要按照Cheery的建议修改原始来源(尽管他/她的回答也很好)。

您也可以只使用回调"加载",它已经到位:

$('#calendar').fullCalendar({
   loading: function(bool) {
      if (bool){
         alert('I am populating the calendar with events');
      }
      else{
         alert('W00t, I have finished!');
         // bind to all your events here
      }
   }
);

实际上您可以自己添加它。像这个一样更新fullcalendar.js中的函数render

function render(inc) {
    if (!content) {
        initialRender();
        trigger('complete', null, true);
    }else{
        calcSize();
        markSizesDirty();
        markEventsDirty();
        renderView(inc);
        trigger('complete', null, true);
    }
} 

并添加到初始调用回调函数:

$('#calendar').fullCalendar({
         editable: true,
         complete: function() {alert('complete');}, 

或者,根据您的需要,您可以访问所有事件

    complete: function() {
        var events = $(this).fullCalendar('clientEvents');
        for(var i in events)
        {
            alert(events[i].title);
        }
    },

这可能已经很久了,但目前有一个官方回调函数(在1.6版本中添加):eventAfterAllRender。不需要修改源代码。

viewRender事件就是这个问题的答案;加载仅适用于内容加载。