Search code examples
jquery-uidraggabledroppable

Draggable, Droppable, and Clone


I'm trying to make a "picture palette", where you have a bunch of images and can drag & drop them to replace the image in a particular div.

Drag works, the drop event registers, but the passed ui object doesn't seem to contain a clone of the dragged image as expected. What's wrong?

JsFiddle.


Solution

  • ui.helper is an array with 1 element. Console logging is an excellent feature that helps debug javascript. You need to either have Chrome, or Firefox with "Developer Tools" plugin installed.

    console.log(ui.helper);
    

    Outputs:

    [<img src=​"http:​/​/​jsfiddle.net/​img/​logo.png" class=​"ui-draggable" style=​"position:​ absolute;​ left:​ 1px;​ top:​ 28px;​ opacity:​ 1;​ ">​]