var icon = $("<div style='width:100px;height:100px;border-style:solid;'>");
icon.draggable({
containment: 'parent',
axis: 'y',
drag: function(e,ui) { }
});
icon.clone(true).appendTo($("body"));
After I have made a clone, icon dragging stopped working. Does anybody know, how to fix this?
Thanks
To clone an element using jQuery, use the jQuery. clone() method. The clone() method clones matched DOM Elements and select the clones. This is useful for moving copies of the elements to another location in the DOM.
The . clone() method performs a deep copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.
Draggable() Method This method allows the elements to be dragged with the help of mouse. Using jQuery UI, we can make the DOM(Document Object Model) elements to drag anywhere within the view port. This can be done by clicking on the draggable object by mouse and dragging it anywhere within the view port.
The draggable functionality does not stop working.
However, when you hold your mouse over the clone and move it around, it is the original element that gets dragged.
Click here to see this behaviour: http://www.jsfiddle.net/bxH3Q/
To get around this, you have to make each clone draggable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With