开发者

jQuery ui.draggable - changing the current dragged object (in fullCalendar)

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. event开发者_StackOverflow社区DragStart 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.


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.


If anyone is interested in the solution I used, I ended up writing my own mini draggable functionality - I just cloned the object during a drag event if the user moved outside of the calendar table, and manually updated the clone's css top/left values until the drag event ended. This means that the original object still gets dragged up and down within the table, which isn't quite ideal, but it's the best solution I could come up with that provides the functionality the client wants.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜