jquery Full Calendar: callback 'after' the

2019-04-21 16:19发布

Is there a callback in Adam Shaw's jquery full calendar which is called after the calendar has rendered completely?? I want to call the clientEvents function in that call back to get all the events on the client side. I tried doing this in viewDisplay, but it is called before the events are rendered and the clientEvents returns 0 events.

4条回答
做自己的国王
2楼-- · 2019-04-21 16:38

This may be WAY old now, but there is currently an official callback function (added in version 1.6): eventAfterAllRender. No source code modification needed.

查看更多
叼着烟拽天下
3楼-- · 2019-04-21 16:42

Actually you can add it by yourself. Update the function render in the fullcalendar.js like this

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

And add to the initial call callback function:

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

or, as you wanted, you can access all events

    complete: function() {
        var events = $(this).fullCalendar('clientEvents');
        for(var i in events)
        {
            alert(events[i].title);
        }
    },
查看更多
ら.Afraid
4楼-- · 2019-04-21 16:44

the viewRender event is the answer to this; loading only works for content loading.

查看更多
Evening l夕情丶
5楼-- · 2019-04-21 16:49

I know this post is rather old now, but if it's any help, you don't need to modify the original source as suggested by Cheery (although his/her answer does work fine as well).

You can also just use the callback 'loading' which is already in place:

$('#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
      }
   }
);
查看更多
登录 后发表回答