来自单个事件源的 RefetchEvents 全日历

RefetchEvents fullcalendar from single event source

我正在使用 fullcalandar jquery 插件,但现在我坚持重新获取日历。 我有两个事件源,我在日历头上制作了自定义刷新按钮。每当用户点击刷新按钮时,我只想从第二个事件源重新获取事件。

有没有办法在 fullcalendar refetchEvents 中传递参数并从单个事件源重新获取。

events: function(start, end, timezone,callback) {
            $.ajax({
                url:  //FIRST EVENT SOURCE
                dataType: 'json',

                success: function(response) {
                    //attaching the response to the calendar
          }

          $.ajax({
                url:  // SECOND EVENT SOURCE
                dataType: 'json',

                success: function(response) {
                    //attaching response to calendar
                 }
             });
       }

每当用户点击自定义刷新按钮时,都会执行 $("#calendar").fullcalendar('refetchEvents'); -- 这将重新获取整个日历(第一个 + 第二个事件源)

我希望做的是,我只想对第二个事件源进行重新获取。

编辑:今天发布了 2.8.0 版,它支持获取单个事件源。我下面的回答是针对旧版本的。

您不想刷新第一个来源,但您仍然需要在屏幕上保留来自第一个来源的事件,我对吗?然后将它们留在临时缓存中。然后,使用全局变量检查用户是否单击了刷新。

var g_FirstSourceEventsCache = null;
var g_IsRefreshClicked = false;

events: function(start, end, timezone,callback) {

          if (g_IsRefreshClicked)   {
             //do not reload from server, load from cache
             callback(g_FirstSourceEventsCache);
             g_IsRefreshClicked = false;
          } else {
            $.ajax({
                url:  //FIRST EVENT SOURCE
                dataType: 'json',

                success: function(response) {
                    //attaching the response to the calendar

                    //save to cache
                    g_FirstSourceEventsCache = myFirstSourceEventsThatIPassedToCallback;
            }
          }

          //second source is always refreshed
          $.ajax({
                url:  // SECOND EVENT SOURCE
                dataType: 'json',

                success: function(response) {
                    //attaching response to calendar
                 }
             });
       }