Mitch Causin
Mitch Causin

Reputation: 1

How to remove a cloned draggable which has been dropped into a container?

I created a widget builder app where you can drag widgets (draggables) onto a widget builder (droppable). Multiple widgets (clones) can be dragged onto the builder, the clones are draggable, and the clones are constrained within the builder.

I have provided a small box in the upper right corner of the widget builder where I would like to use it as a trash can (of sorts; to remove the clone if dragged onto it).

Can someone help me with creating the ability to remove a clone if the clone is dragged onto the trash area?

Here is my example: http://jsfiddle.net/mitchslap/K8VKa/

Thank you thank you thank you!

Upvotes: 0

Views: 2554

Answers (1)

radzi0_0
radzi0_0

Reputation: 1387

Set 'greedy' param to 'true' in drop function in your droppable container:

$("#trashWidget").droppable({
    greedy: 'true',
    accept: function() { return true; },
    drop: function () { tolerance: 'fit', alert("Dropped!"); }
});

I've just tested this function and it seems to work flawlessly :)

Good luck!

Upvotes: 2

Related Questions