【问题标题】:RefetchEvents fullcalendar from single event source来自单个事件源的 RefetchEvents fullcalendar
【发布时间】:2016-06-18 05:13:57
【问题描述】:

我正在使用 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');——这将重新获取整个日历(第一个 + 第二个事件源)

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

【问题讨论】:

  • 您应该尝试使用此选项。 1. 销毁日历 2. 重新创建日历。或者您可以选择 1. 刷新日历。
  • 例如 $("#cal").fullCalendar('refresh');
  • 感谢您的回复.. 如果您刷新,那将从两个事件源刷新。如果我错了,请纠正我。我想刷新单个事件源。
  • 到目前为止你尝试了什么代码?
  • 如果日历中只有两个事件,那么再次获取两个事件并在那里显示有什么问题吗?

标签: jquery fullcalendar fullcalendar-scheduler


【解决方案1】:

编辑:今天发布了 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
                 }
             });
       }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-10
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多