开发者

How to check for number of events on agendaDay and basicDay views

I want to disable the calen开发者_开发技巧dar if there are no events for the day (I'm using it on a sidebar in basicDay view). Does anyone know how I can check for the number of events so I can disable the calendar if there are none?

Help is much appreciated! Thanks in advance.


You can use the following callbacks to find out if there is any data in a view:

var numEvents = 0;
$("#calendar").fullCalendar({
    loading: function(isLoading, view) {
        if(isLoading) { // starting to fetch events
            numEvents = 0;
        } else { // done fetching events
            if(numEvents == 0) {
                // disable calendar
            } else {
                // ensure calendar is enabled
            }
        }
    },
    eventAfterRender: function(event, element, view) {
        numEvents++;
    }
});

Since FullCalendar only loads events for the current view, to figure out which view has new data (unless you store them all on the client side), you'll want to implement code on the server side that can return the next date with an event. You can then use gotoDate on the calendar to go to that date once you get it from the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜