jquery-week-calendar icon indicating copy to clipboard operation
jquery-week-calendar copied to clipboard

First resize after drag&drop fails if you do an "updateEvent" in the eventDrop handler

Open ghost opened this issue 14 years ago • 0 comments

If you call $calendar.weekCalendar("updateEvent", newValEvent); in the eventDrop handler, you'll get unexpected behavior - the first attempt to resize an event after a drag&drop will fail.

I found out that it's simply not necessary to do an "updateEvent" in the handler, because the new calendar event will be rendered after the handler is called anyway.

I spent quite a few hours chasing this down, and I think it would be nice to document it for the benefit of other users.

If you do an "updateEvent" in your eventDrop handler, the value of $calEvent.data("calEvent") will be null in the function addDroppableToWeekDay, which will then crash at the following line: var $weekDayOld = self._findWeekDayForEvent($calEvent.data("calEvent"), self.element.find(".wc-time-slots .wc-day-column-inner"));

Since addDroppableToWeekDay never finishes, $calEvent (the old one) never gets removed. Now if you try to resize the event using the gui, $calEvent gets picked up by the collision detection logic in adjustForEventCollisions. The end result is that your resized event reverts to its original dimensions. This is all similar to issue 115 on the old list:

http://code.google.com/p/jquery-week-calendar/issues/detail?id=115

ghost avatar Dec 11 '10 02:12 ghost