简体   繁体   中英

Fullcalendar updateEvent isn't rendering the event properly

I'm using updateEvent method to update an event on the fly in the week view.

$('#calendar').fullCalendar( 'updateEvent', event);

It works fine If I'm updating the date of the event (It is moving fine across the allDay slots). But If I'm changing the start / end time of the existing event, I don't see the event after the updateEvent (which means the updated event is disappeared)

I see the event object in the console

start: Object, end: null, // For the old event. Object is moment, converted by fullcalendar
start: '2017-02-14T07:00:00', end: '2017-02-14T08:00:00' // Updated date and time

So, clearly I'm setting the date and time properly. I've no idea why it is not working. Any suggestion?

I solved the issue.

I tried removing the old event by using removeEvents and created a new event by calling the renderEvents . Still the same issue.

Then I tried removing all the properties starts with _ from the event object and it worked when I removed the source object from the fullcalendar's .

From the docs, source is automatically populated and it is the reference to the event source that this event came from.

So clearly, when we are updating the event, we have to remove the source property of the event otherwise it may still refer to the old one.

Here is my code.

$('.calendar').fullCalendar('removeEvents', oldEvent._id);
delete oldEvent._id;
delete oldEvent._allDay;
delete oldEvent._start;
delete oldEvent._end;
delete oldEvent.source;
$('.calendar').fullCalendar('renderEvent', oldEvent, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM