JQuery ui.draggable – changing the current dragged object (in fullCalendar)

clonedraggablejquery-ui

I've just discovered the fullCalendar jQuery plugin which does pretty much everything I need for the appointment scheduling service I'm building. However, I've hit a small problem.

There are "event" elements within fullCalendar agendaDay view which are draggable, however they are locked to the tds of available timeslots. I want to preserve this snapping to the timeslots, but also make it possible to drag the event totally outside of the calendar (this is a behaviour requirement from an older version of the system).

My idea was to make a clone of the object on a mouseout event for the calendar table; this works, but then the user must click and drag the clone seperately from the original object, rather than the clone taking over being dragged.

I need to transfer the "I'm being dragged" status to the clone once the user tries to drag the "event" element outside the table. Is this somehow possible? Is there perhaps an easier solution I could use?

Here is my code which does the cloning. eventDragStart is a "triggered action" called when a user starts to drag an event about (http://arshaw.com/fullcalendar/docs/triggered-actions.php), in which $(this) is set to the event element, event is the calEvent (the actual data item – not relevant here), js is the javascript event (where I get the coordinates), an ui is the ui object reference. ".fc" is the calendar, "#display_box" is the parent element containing this part of the interface. (BTW the positioning doesn't work right yet, but that's kind of a secondary priority right now).

...
eventDragStart: function (event, js, ui) $\{   
var eventElement = $(this);
 $(".fc").mouseout(function () {
  eventElement.clone().css({'z-index':99999, top:js.clientY, right:js.clientX).appendTo("#display_box").draggable({helper: 'original'}); 
  $(".fc").unbind("mouseout");
 });
},
....

I hope this is clear to anyone who hasn't used fullCalendar. I'd really appreciate any help, and sorry it's so long.

Best Answer

Well i think youll want to use eventElement.clone(true) passing that boolean true as an argument is going to clone all the attached events/handlers for the element, where as not passing is only going to clone the dome element wrapped in jQ.

Related Topic