Basically, I have a list of draggable elements and initially one droppable element for dragging them. When an item is dragged into droppable, the droppable is cloned (before the item is added) and is added to the new area as resettable.
Take a look at this stripped-down script: http://jsfiddle.net/DKBU9/1/ (missing sortable ())
HTML
<ul id="draggables"> <li>foo1</li> <li>foo2</li> <li>foo3</li> </ul> <ul class="droppable new"> </ul>
Js
$('#draggables > li').draggable({ appendTo: 'document', revert: 'invalid' }); $('.droppable > li').draggable({ appendTo: 'document', revert: 'invalid' }); $('#draggables').droppable({ accept: '.droppable > li', drop: function(event, ui) { ui.draggable.detach().css({top: 0,left: 0}).appendTo($(this)); } }); $('.droppable').droppable({ accept: '#draggables > li', drop: function(event, ui) { if($(this).hasClass('new')) { var clone = $(this).clone(true, true); $(this).removeClass('new').after(clone); } ui.draggable.detach().css({top: 0,left: 0}).appendTo($(this)); } });
As you can see, drag and drop is done for the original elements, but not stored in the clone. I thought that clone(true, true) copied the corresponding and child elements and their event handlers.
I even tried putting the above JS in a function and running that function in drop events, but got nothing.
Ultimately, I want to be able to drag between the pool list and the cloned lists and between the cloned lists themselves, and also sort the items in the cloned lists.
jquery clone jquery-ui jquery-ui-droppable jquery-ui-draggable
Bobe
source share