简体   繁体   English

使用全日历修改事件结束日期

[英]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. 我也尝试过eventAfterRender,导致同样的错误。

You do not seem to need to call within event handler. 您似乎不需要在事件处理程序中调用。 Remove $('#calendar').fullCalendar('updateEvent', event); 删除$('#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 另外,您还需要检查event.end是否不为null,因为如果是1天事件,则它将为null

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

Works for me. 为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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