javascriptjqueryjquery-uijquery-ui-draggablejquery-draggable

Jquery UI Draggable clone disappearing


I am trying to use the jquery-ui draggable to make some element draggable. I set the helper option to clone the current element.
It's making the clone correctly but when I drop the clone disappears. It doesn't stay at the dragged place.

See this for Demo Fiddle Link

$('#drag').draggable({
helper: function (e, ui) {
    return $(this).clone();
}
});

What am I missing ?


Solution

  • There maybe a simpler way, but through data of draggable, you can target a property that deals with this. Like this:

    stop : function(e, ui){
             $('#drag').draggable().data()["ui-draggable"].cancelHelperRemoval = true;
        }
    

    fiddle: http://jsfiddle.net/n10ucrLd/