Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fullcalendar return event end null when allDay is true

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

like image 717
Mr.Vertigo Avatar asked Jul 06 '14 13:07

Mr.Vertigo


People also ask

How do I start and end date in fullCalendar?

We can get start date by getView event with intervalStart. We can get end date by getView event with intervalEnd. var month = $('#calendar'). fullCalendar('getView').

How do I set events in fullCalendar?

Here is an example of how to specify an array of events: var calendar = new Calendar(calendarEl, { events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09T12:30:00', allDay : false // will make the time show } ] });

How do I save events in fullCalendar?

You need to implement the eventResize to save the effect of dragging the event across days. ideally, create a function to post your data and call it from each event. function saveMyData(event) { jQuery. post( '/event/save', { title: event.

How do I hide time in fullCalendar?

This option is available from v2. 4.0 see fullcalendar.io/docs/text/displayEventTime - You need to set it as option of fullCalendar and it affects all events. Or use CSS . fc-time{ display : none; } .


2 Answers

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

like image 174
Vaibhav Jain Avatar answered Oct 11 '22 07:10

Vaibhav Jain


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.

like image 38
Jan Peša Avatar answered Oct 11 '22 06:10

Jan Peša