how to update an event in fullCalendar?

后端 未结 2 1885
野趣味
野趣味 2021-02-09 04:14

I want to update my json in fullcalendar, Here is what I am exactly trying to do. I have a JSON string which I am directly trying to feed in to the event objects in the full ca

2条回答
  •  执笔经年
    2021-02-09 04:59

    You aren't calling the correct fullCalendar method to render the new events.

    This will not work because it is only meant to render the events the first time around:

       $("#demo-calendar").fullCalendar('renderEvents', JSON);
    

    Instead you need to remove the events on the calendar and refresh them:

       $("#demo-calendar").fullCalendar('removeEvents'); 
       $("#demo-calendar").fullCalendar('addEventSource', JSON); 
    

    Check the Fiddle: http://jsfiddle.net/shaunp/u8Ksw/29/

    NOTE that there is a fullCalendar method called refetchEvents, but that it does NOT work on an array of events such as what you have created, so you must manually take the events off and re-add the event source again.

提交回复
热议问题