简体   繁体   中英

Modify event end date with fullcalendar

Is there a way to add one day to the event's end date before it is rendered on the calendar? I have tried the following code which gives a Maximum call stack size exceeded error in the console:

eventRender: function(event, element) {
            if(event.allDay){
                event.end.add(1, 'days');
                $('#calendar').fullCalendar('updateEvent', event);
                console.log(event.end);
            }
}

I have also tried the eventAfterRender which results in the same error.

You do not seem to need to call within event handler. Remove $('#calendar').fullCalendar('updateEvent', event);

Also you need to check if event.end is not null, as in case of 1 day event it will be null

eventRender: function(ev, el, v) {
        if(ev.allDay && ev.end){
            ev.end.add(1, 'days');
            console.log(ev.end);
        }
} 

Works for me.

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