Nathan_Sharktek
Nathan_Sharktek

Reputation: 407

jQuery UI - Draggable Helper Clone

Thank you in advance for taking a look at this!

My Goal:

What is happening:

The clone option was the only way I was able create a new instance of the a draggable object, perhaps I'm thinking in the wrong direction.

I am creating a clone as such:

$(".objectDrag").draggable({
    helper:'clone'
});  

$("#artCanvas").droppable({
    accept: ".objectDrag",
    drop: function(event,ui){
        var new_smiley = $(ui.helper).clone();
        $(this).append(new_smiley );
    }
});

Here is a JSFiddle for a visual of what is occurring: http://jsfiddle.net/YRfVd/55/

Please let me know if I am being unclear in anyway or could provide further explanation. Again, thank you so much for taking the time to look at this--you guys are awesome!

Nathan

Upvotes: 5

Views: 10631

Answers (1)

Chitrang
Chitrang

Reputation: 2114

You can initialize drag functionality on clone by draggable() function and remove class objectDrag so that newly added objects do not start to create their own clones.

$(".objectDrag").draggable({
    helper:'clone'
});  

$("#artCanvas").droppable({
    accept: ".objectDrag",
    drop: function(event,ui){
        var new_signature = $(ui.helper).clone().removeClass('objectDrag');
        new_signature.draggable();
        $(this).append(new_signature);
    }
});

JSFiddle: http://jsfiddle.net/YRfVd/56/

Upvotes: 11

Related Questions