我會製作自己的緩存對象,並將它用於fullcalendar初始化器中的events
函數。這種方法使得「活動作爲函數」讓你的事件數據的方法的使用: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