Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  21] [ 2]  / answers: 1 / hits: 25767  / 16 Years ago, sun, march 8, 2009, 12:00:00

i want to be able to create a copy of the element that i want to drag. im using the standard ui draggable and droppable. i know about the helper clone option. but that does not create a copy. the dragged item gets reverted back to the original position.


More From » jquery

 Answers
17

Mark,



Try this example:



        $(document).ready(function(){
$(.objectDrag).draggable({helper:'clone'});

$(#garbageCollector).droppable({
accept: .objectDrag,
drop: function(event,ui){
console.log(Item was Dropped);
$(this).append($(ui.draggable).clone());
}
});

});


And the Html looks like this



        <div class=objectDrag 
style=width:10%; color:white;border:black 1px solid; background-color:#00A>Drag me</div>

<div id=garbageCollector style=width:100%; height:400px; background-color:#333; color:white;> Drop items on me</div>

[#99877] Monday, March 2, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kinsley

Total Points: 352
Total Questions: 84
Total Answers: 94

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
;