即使删除所有事件,FullCalendar也会插入重复事件

时间:2011-11-03 15:53:32

标签: fullcalendar

FullCalendar除了我遇到的1个问题外,工作得很好。 在月视图模式下加载日历的月视图div似乎显示加载了重复的假日。当我添加一个事件,然后调用我的日历绑定函数时,会发生这种情况,该函数基本上运行下面的代码。

还有其他人有过类似的问题吗?看起来'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);
        }
    });

1 个答案:

答案 0 :(得分:5)

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

('data'是应用程序提供的json事件数组,'googleCalendarUkHolidayFeed'是谷歌的网址提要。)

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);        
}