JSON Fullcalendar Channel Caching

How can I get Fullcalendar for caching events from a JSON feed?

I do not think that lazyfetchingdoes what I want. He works for one month. Let's say I load the month, January, and then change the view of the day, the data is cached and does not send an ajax request. But if I change the months to February and return in January, January is still rebooting.

The author tried to fulfill the request in March 2011 , but, in my opinion, still failed. It allows the browser to cache the result of the request , but it hits or misses and depends on the browser settings.

Any ideas? Did I miss something?

+3
source share
2 answers

I would make my own caching object and use it in a function eventsin the fullcalendar initializer. This method uses the Events as a Function method to retrieve your event data: http://arshaw.com/fullcalendar/docs/event_data/events_function/

$("#calendar").fullCalendar({

// init options

// go

//here,
    events: function (start, end, callback) {

        //have we already cached this time?
        if (events.eventsCache 
            && events.eventsCache[start.toString + "-" + end.toString]){

                    //if we already have this data, pass it to callback()
            callback(eventsCache[start.toString + "-" + end.toString]);
            return;
        }



        //we haven't gotten this time range (month) yet. get it, and pass it to callback()
        $.get("where_my_events_live.php", function(data){
            if (!events.eventsCache)
                events.eventsCache = {};

            //store your data
            eventsCache[start.toString + "-" + end.toString] = data;
            callback(data);
        });
    },

..r
+3
source

I accomplish this using backbone.js with fullcalendar. http://blog.shinetech.com/2011/08/05/building-a-shared-calendar-with-backbone-js-and-fullcalendar-a-step-by-step-tutorial/ provides a code and tutorial explaining this. This is a bit of an extreme solution for what you are asking for, but the benefits of using backbone.js with fullcalendar may be worth exploring.

+1

Source: https://habr.com/ru/post/1666695/


All Articles