2011-11-03 84 views
2

FullCalendar除了我遇到的1个问题外,还有很大的工作量。 在monthview模式下加载日历的monthview div似乎显示重复的假日加载。当我添加一个事件,然后调用我的日历绑定函数(基本运行下面的代码)时,会发生这种情况。FullCalendar即使在删除所有事件时也会插入重复事件

有没有其他人有类似的问题?它看起来像'removeEvents'功能工作正常对数据源来自内部数据库,但似乎离开了谷歌日期。当调用addEventSource时,它会再次添加相同的事件。

var googleUkHolidaysFeed = { 
    url: 'http://www.google.com/calendar/feeds/uk__en%40holiday.calendar.google.com/public/basic', 
    cache: true, 
    color: "green"  
}; 

$.getJSON(url, {}, function (data) { 

     $('#dayview').fullCalendar('removeEvents'); 
     $('#dayview').fullCalendar('addEventSource', data);   

     if ($("#monthview")[0]) { 
      $('#monthview').fullCalendar('removeEvents'); 
      $('#monthview').fullCalendar('addEventSource', data); 
      $('#monthview').fullCalendar('addEventSource', googleUkHolidaysFeed); 
     } 
    }); 

回答

5

我自己解决了这个问题。 'removeEvents'必须被调用,然后是'removeEventSource',如下所示:

('data'是由应用程序提供的事件的json数组,'googleCalendarUkHolidayFeed'是来自google的url提要)。

var googleCalendarUkHolidayFeed = { 
    url: "http://www.google.com/calendar/feeds/bla..."  
}  

$('#dayview').fullCalendar('removeEvents');  
$('#dayview').fullCalendar('addEventSource', data); 

if ($("#monthview")[0]) { 
    // remove events and re-add event source to reflect search/non-search 
    $('#monthview').fullCalendar('removeEvents'); 

    $('#monthview').fullCalendar('removeEventSource', googleCalendarUkHolidayFeed); 
    $('#monthview').fullCalendar('removeEventSource', data);   

    $('#monthview').fullCalendar('addEventSource', googleCalendarUkHolidayFeed); 
    $('#monthview').fullCalendar('addEventSource', data);   
}