Fullcalendar JSON供稿缓存 [英] Fullcalendar JSON Feed Caching

查看:117
本文介绍了Fullcalendar JSON供稿缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何才能 Fullcalendar 缓存来自JSON Feed的事件?

How can I get Fullcalendar to cache events from a JSON feed?

我不认为 lazyfetching 做我想要的。它工作一个月。假设我加载了一个月,一月,然后切换到日视图,数据被缓存,并且不发送ajax请求。但如果我将月份更改为2月份并返回至1月份,则1月份仍会重新加载。

I don't think lazyfetching does what I want it to. It works for a single month. Say I load a month, January, and then change to the day view, the data is cached and does not send an ajax request. But If I change months to Feb and back to Jan, January still reloads.

作者试图在2011年3月完成请求,但我相信仍然不足。他让浏览器可能会缓存请求的结果,但这会被击中或错过,并取决于浏览器设置。

The author attempted to accomplish the request back in March of 2011 but still fell short, I believe. He lets the browser possibly cache the result of a request, but this is hit or miss and depends on browser settings.

任何想法?我错过了什么?

Any ideas? Am I missing something?

推荐答案

我会制作自己的缓存对象,并将它用于 events 函数在fullcalendar初始化器中。此方法利用事件作为函数来获取事件数据: http:/ /arshaw.com/fullcalendar/docs/event_data/events_function/

I would make my own caching object and use it in the events function in the fullcalendar initializer. This method makes use of the "Events as a function" method of getting 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

这篇关于Fullcalendar JSON供稿缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆