除了我遇到的1个问题,FullCalendar工作得很好.在月视图模式下加载日历的月视图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);
}
});
Run Code Online (Sandbox Code Playgroud)
我自己解决了这个问题.必须调用'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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4898 次 |
| 最近记录: |