Fullcalendar Duplicate entries on change of view
I'm having trouble with duplicates when changing views on fullcalendar after an update. I call the following function after and add/edit/erase or change of selected users.
var u=''; $('#tree1 li.user.jstree-checked').each(function() { u=u+'&Showuser='+$(this).attr('id'); });
var jsonFeed = "cal.cgi?events=y"+u;
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', jsonFeed);
When in month view this works fine but in da开发者_运维百科y or week view it also seems to work, e.g. no duplicates but then when I change to month view it reloads two or more sets of the feed.
I think that the removeEvents
is only removing the events from the current view.
Maybe it's how I'm loading the events in the first place.
See the documentation to remove previous event source http://arshaw.com/fullcalendar/docs/event_data/removeEventSource/
removing previous event source and adding new event source will not cause duplicate events in the calendar.
What I did in mine was to remove all of the ID's from the calendar before adding new events, or the same events again for a different view.
for(var i=0;i<=json.events.length-1;i++){
$('#calendar').fullCalendar("removeEvents",json.events[i].id);
}
$('#calendar').fullCalendar("addEventSource",json);
精彩评论