最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - fullcalendar return event end null when allDay is true - Stack Overflow

programmeradmin4浏览0评论

I don't know if it is a feature or a bug. But the event end value is set to null if allDay is true. This is the function where the event is updated:

 change: function (eventModel) {


                var currEvId = eventModel.get('_id');
                var fcEvent = $("#calendar").fullCalendar('clientEvents', currEvId)[0] || {};
                 console.log("end before update : " + fcEvent.end);

                fcEvent.title = alvEventModel.get("title");                 
                fcEvent.start = new Date(alvEventModel.get("start"));
                fcEvent.end = new Date(alvEventModel.get("end"));
                fcEvent.allDay = alvEventModel.get("allDay");  //true or false              
                this.el.fullCalendar('updateEvent', fcEvent);

                console.log("start: " + fcEvent.start);
                console.log("end: " + fcEvent.end);      

            },

The console shows

end before update : 1404896400000
end after update: null 

The fullcalendar property forceEventDuration is setted to true

this.$el.fullCalendar({
                    lang: 'sv',
                    header: {
                        left: 'prev,next, today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay',
                        ignoreTimezone: false
                    },
                    forceEventDuration:true,
                    select: this.select,
                    selectable: true,
                    selectHelper: true,
                    editable: true,


                    disableDragging: true,
                    disableResizing: true,

                    aspectRatio: 2.5,
                    height: 600,
                    weekNumbers: true,
                     ...
                    })

the the console shows

end before update : 1404864000000
end after update: 1404813300000 

I this case the rendering for the event is one day. Even after updating with allDay to false it continue to show as a one day event until reloading the events from server. I think the standard behavior is for allDay must have a start and end date. But I'm not sure the intentions of declaring the end date as null. May be I missunderstand the beauty of this behavior. I don't know how to use for my goals. I need an end date like other calendars.

/ And the version is v2.0.2

I don't know if it is a feature or a bug. But the event end value is set to null if allDay is true. This is the function where the event is updated:

 change: function (eventModel) {


                var currEvId = eventModel.get('_id');
                var fcEvent = $("#calendar").fullCalendar('clientEvents', currEvId)[0] || {};
                 console.log("end before update : " + fcEvent.end);

                fcEvent.title = alvEventModel.get("title");                 
                fcEvent.start = new Date(alvEventModel.get("start"));
                fcEvent.end = new Date(alvEventModel.get("end"));
                fcEvent.allDay = alvEventModel.get("allDay");  //true or false              
                this.el.fullCalendar('updateEvent', fcEvent);

                console.log("start: " + fcEvent.start);
                console.log("end: " + fcEvent.end);      

            },

The console shows

end before update : 1404896400000
end after update: null 

The fullcalendar property forceEventDuration is setted to true

this.$el.fullCalendar({
                    lang: 'sv',
                    header: {
                        left: 'prev,next, today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay',
                        ignoreTimezone: false
                    },
                    forceEventDuration:true,
                    select: this.select,
                    selectable: true,
                    selectHelper: true,
                    editable: true,


                    disableDragging: true,
                    disableResizing: true,

                    aspectRatio: 2.5,
                    height: 600,
                    weekNumbers: true,
                     ...
                    })

the the console shows

end before update : 1404864000000
end after update: 1404813300000 

I this case the rendering for the event is one day. Even after updating with allDay to false it continue to show as a one day event until reloading the events from server. I think the standard behavior is for allDay must have a start and end date. But I'm not sure the intentions of declaring the end date as null. May be I missunderstand the beauty of this behavior. I don't know how to use for my goals. I need an end date like other calendars.

http://jsfiddle.net/Mr_Vertigo/k3RZX/1/ And the version is v2.0.2

Share Improve this question edited Jul 7, 2014 at 17:36 Mr.Vertigo asked Jul 6, 2014 at 13:56 Mr.VertigoMr.Vertigo 1511 silver badge7 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 15

This issue is not because of allday is set to true. Fullcalendar has one issue that if start date and end date are same it simply makes end date as null.

If the event's end date is the same as the start date, FullCalendar considers it to be 1-day in duration (with a blank assumed end time), so it is one-in-the-same. It prefers to store less data than more. So carefully check if start date and end date are coming same.

But you could simply do this as a workaround:

eventClick: function(event) {
    var start = event.start;
    var end = event.end || start;
}

Check following link.

https://code.google.com/p/fullcalendar/issues/detail?id=1014

It does not need to be set, because you have defaultAllDayEventDuration option. Also forceEventDuration does not apply to all day events (see here)

If you don't want end to be null, then just set it manualy.

FullCalendar always set end to null when allDay changes as you can see in the doc. Line 1886

if (newAllDay != oldAllDay) {
        // if allDay has changed, always throw away the end
        clearEnd = true;
}
发布评论

评论列表(0)

  1. 暂无评论