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

khi*_*zar 9 javascript jquery callback fullcalendar

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

Chr*_*ris 22

我知道这篇文章现在已经很老了,但是如果它有任何帮助,你不需要按照Cheery的建议修改原始来源(尽管他/她的答案也可以正常工作).

您也可以使用已经存在的回调'loading':

$('#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
      }
   }
);
Run Code Online (Sandbox Code Playgroud)

  • 值得注意的是:只有在需要从某个地方(IE,通过函数调用或URL)加载事件时才能加载.如果您只是将事件作为JSON传递,则加载将(至少从1.5.5开始)不会触发. (13认同)

Che*_*ery 9

实际上你可以自己添加它.更新功能renderfullcalendar.js这样的

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

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

$('#calendar').fullCalendar({
         editable: true,
         complete: function() {alert('complete');}, 
Run Code Online (Sandbox Code Playgroud)

或者,如您所愿,您可以访问所有活动

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


Bla*_*lly 7

现在可能已经过时了,但目前有一个正式的回调函数(在1.6版中添加):eventAfterAllRender.无需修改源代码.