Home    Articles

 

FullCalendar new rendered/extended object, id missing or overwrited with _fc1 SOLVED

 

I've upgraded my FullCalendar from an older version to a newer one (2.2.6) and a new issue occured.

Issue:

When a new droppable event had to be created the assigned id that i've provided was overwritten with "_fc1" . Obviously my next attempts to move/edit/delete this event from the calendar were in van becouse of the wrong event.id.

Sollution: 

drop: function (event, dayDelta, minuteDelta, allDay, revertFunc) { // or eventDrop, doesn't matter
		//do a copy of the original event
                //make sure the  "true" is in the $.extend method otherwise will NOT WORK
                var eventCopied = $.extend(true, {}, event)
                //change the _id  variable
                eventCopied._id = "123";
                //set the start and date to the start date of the dropped event
                //for any reason if you don't set the ._start and .start, this will NOT WORK
                eventCopied._start = event._start;
                eventCopied.start = event._start;

                eventCopied._end = event._end;
                eventCopied.end = event._end;

                // here you can make an ajax call to save the data into your database
				saveToDB();
				
                //render the copied event to the calendar
                $("#calendar").fullCalendar('renderEvent', eventCopied)
			},
			eventResize: .....
			......

 

Follow the steps in this code and your code should work.

Enjoy.

 

by