Tuesday 15 May 2012

javascript - Avoid event superposition in FullCalendar -


Hello I'm trying to avoid overlapping incidents in an FullCalendar app. EventDrop has defined the callback, so it checks any overlapping events, and transfers the currently moved event to the end of the overlapping by changing the event.start and Event.end accordingly, and then calling .fullCalendar ('updateEvent', event) .

This is my code, is the moment call for which there is a time handling feature library for javascript and I do not think the problem is copy if I comment on those links I do that, event.start = start; Event.end = end , then all works normally if I do not, then it breaks in exactly the same way, whether or not I call on updateEvent Is: The event is transferred to the end of the last one, but if I try to transfer this event later (in the day after that place) then the last event will be visually expanded. Is not new beginning Shall be given phenomena occurring at present revised.

self.collection is a backbone collection, so this code is called with just event.start = bit comment overlapping, but if I If the page refreshes, the event appears in their right spot (not overlapping)

  eventDrop: function (Event, Dedata, Minute Delta, Olde, ReverseFunk, JSEvent, UI, V) { Var start = moment (event.start); Var end = moment (event.end); Var overlap = self.calendar.fullCalendar ('clientEvents', function (ev) {if (ev == event) return false; var estart = moment (ev.start); var eend = moment (ev.end); return estart .unix () & lt; end.unix () and eend.unix () & gt; start.unix ();}); If (overlap lamb) {overlap = overlap [0]; Var estart = moment (overlap.start); Var end = moment (overlap.and); Var period = termination - estart; Start = eend; End = start.clone (); End.add (period); Event.start = start.toDate (); Event.end = end.to Date (); Self.calendar.fullCalendar ('updateEvent', Event); } Event.model.save ({start: start.unix (), end: end.unix ()}); },    

Okay, got the problem.

The row that says

  start = end;   

should be

  start = eend.clone ();   

Because it does not do this by wrapping it into a moment object, it just puts a reference, and it's start date object Code> overlap.end

No comments:

Post a Comment