I'm dragging elements from one unordered list to another:
$('ul#drag li').draggable({ helper: 'clone' });
$('ul#drop').droppable({
drop: function (event, ui) {
ui.draggable.sourceElement.css(... ...);
}
});
I want to mark already dragged elements in source list (but still allow dragging them), how do I access them through jQuery chain?
I guess I can set id
attribute on the dragged element, and when dropping, the cloned element would have the same id
, which I can use in finding the original, but I'm sure there's a nicer solution.
Droppable() Method: This method allows the elements to be dropped with the help of mouse. Using jQuery UI, we can make the DOM(Document Object Model) elements to drop anywhere within the view port on the specified target. This can be done by clicking on the draggable object by mouse and drop it on the specified target.
You have one of these problems: Your jQuery or jQuery UI Javascript path files are wrong. Your jQuery UI does not include draggable. Your jQuery or jQuery UI Javascript files are corrupted.
jQueryUI provides draggable() method to make any DOM element draggable. Once the element is draggable, you can move that element by clicking on it with the mouse and dragging it anywhere within the viewport.
I wonder why I did not notice that the following works, the first time I tried it:
ui.draggable.css('whatever');
It's even documented:
ui.draggable - current draggable element, a jQuery object.
e.target
refers to the original element
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