当使用jquery fullCalendar,为什么我看到交换个月后重复事件? [英] When using jquery fullCalendar, Why am i seeing duplicate events after switching months?

查看:378
本文介绍了当使用jquery fullCalendar,为什么我看到交换个月后重复事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用jquery fullCalendar插件,然后我遇到了一个奇怪的问题。

I am using jquery fullCalendar plugin and i am running into a weird issue.

当我加载的第一个月(2013年12月在这种情况下),它工作正常。我打电话给我的AJAX事件,并返回一组事件。我返回从我的服务器40事件,我看到40事件呈现。

When i load the first month (December 2013 in this case) it works fine . I call my ajax event and return a set of events. I return 40 events from my server and i see 40 events render.

我然后移动到下个月(2014年1月),它也能正常工作。 (从服务器41事件和41事件显示在图形用户界面)

I then move to the next month (Jan 2014) and it also works fine. (41 events from the server and 41 events show up in the GUI)

我然后单击后退改回2013年12月,我也得到了AJAX事件,这将返回相同的40个事件(如上),但是当日历加载看到每一个事件在十二月重复(80事件显示在图形用户界面)即使我只能从服务器发回40,我看到40事件的回调过程中。

I then click BACK to change back to December 2013 and i get the ajax event, which returns the same 40 events (as above) but when the calendar load it see every event in December duplicated (80 events are shown on the GUI) even though i only send back 40 from the server and i see 40 during the events callback.

下面是我的code:

$('#calendar').fullCalendar({
  header: {
    left: 'prev,next title today',
    right: ''
  },
  lazyFetching: false,
  editable: false,
  timeFormat: 'H:mm{-H:mm} ',

  viewDisplay: function (view) {
    ViewDisplay();
  },

  events: function (start, end, callback) {

    $('#Month').val($('#calendar').fullCalendar('getDate').getMonth() + 1);
    $("#Year").val($('#calendar').fullCalendar('getDate').getUTCFullYear());

    var serializedFormInfo = $('#rotaForm').serialize();

    $.ajax({
      url: '/SupportRota/GetEvents/',
      dataType: 'json',
      cache: false,

      data: serializedFormInfo,
      success: function (data) {
        callback(data.RotaEvents);
      }
    });
  }
});

我尝试添加lazyLoading:假的,因为我认为这是某种形式的缓存,但是这似乎并没有解决问题。

I tried adding lazyLoading: false as I assumed it was some sort of caching, but that doesn't seem to solve the issue.

我把一个断点在Firebug就行

I put a breakpoint in firebug on the line

callback(data.RotaEvents)

和我看到40事件,但80事件表明了上述的场景时,屏幕上。

And i see 40 events but 80 events show up on the screen during the scenario stated above.

任何建议?

推荐答案

或许是骨灰级的答案,但简单:我认为事件可能被缓存在浏览器中,并解释为什么你有重复

Maybe an "hardcore" answer, but simple : I think that the events may be cached in the browser and explain why you have duplicates.

你的 AJAX 调用之前刚刚加入这一行:

Just add this line before your ajax call :

$('.fc-event').remove();

您不必担心,如果此事件已经呈现与否,这可能会更快加载的任期。

You don't have to worry about if this event is already rendered or not, and that may be quicker in term of loading.

这篇关于当使用jquery fullCalendar,为什么我看到交换个月后重复事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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