Using .delegate to start dragging
The .delegate() method of jQuery 1.4 allows one to apply "true" event delegation. How would one go about to using it to delegate dragging in the jQuery UI 1.7.2? One could have achieved this by triggering the namespaced event for dragging in the old 1.6.x version of the UI library.
I have tried to trigger the mousedown event, but one need to pass on the original event as well. The intended usage is to make something draggable on mousedown, pass on the event and triggering the drag start, and then to destroy the drag events after the dragging has stop, see the code below:
- $("ul#dynamiclist").delegate("li", "mousedown", function(event) {
- $(this).draggable({
- helper: "clone",
- stop: function(ev, ui) {
- $(this).draggable("destroy");
- }
- });
- });
Has anyone attempted something like this before?