FullCalendar javascript - refetchEvents not updating calendar

May 2024 ยท 1 minute read

When I update the 'events' object with a new event and call calander.fullCalendar('refetchEvents') the calendar is not refreshed.

Example:

events = [ { title : 'event1', start : '2015-11-01' } ]; calendar = jQuery("#calendar").fullCalendar({ events: events }); events = [ { title : 'event2', start : '2015-11-02' } ]; console.log(events); calendar.fullCalendar('refetchEvents'); 

Still only shows 'event1' even though I expect 'event2' to show up.

http://jsfiddle.net/u1fjfbzw/

1 Answer

A simplistic way to get event1 and event2 to both show up is add events array again as an event source. http://jsfiddle.net/u1fjfbzw/1/

events = [ { title : 'event1', start : '2015-11-01' } ]; calendar = jQuery("#calendar").fullCalendar({ events: events }); events = [ { title : 'event2', start : '2015-11-02' } ]; /* This will make it show up */ calendar.fullCalendar('addEventSource', events); calendar.fullCalendar('refetchEvents'); 

The 'events' array in your code is separate from fullCalendar's internal events. From fullcalendar.js 2.4.0:

else if (typeof sourceInput === 'object') { source = $.extend({}, sourceInput); // shallow copy } 
4

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJoamxuZWmDeISOn6ylpJOWuaa6w5qpZqKRq660r9Gip61lopqzpsDCoZyvnZ6pwG66zq1krqiUlsGqusZmmpqklaOxor4%3D