I have a container with different draggable -elements and there is a list of some \"target\" divs, where the user can drop the draggable elements.
Example: Imagine,
First, you should make sure to never have two elements with the same id in the page. So when dropping, you want to change the id in some manner, e.g.:
$('#doclist').droppable({
drop: function( event, ui ) {
tag=ui.draggable;
tag.clone().attr("id", "copy-" + tag.attr("id")).appendTo( this );
}
});
Next, indeed you could use accept and checking the DOM. Don't worry, I don't think it will be too resource intensive. Something like:
$('#doclist').droppable({
drop: function( event, ui ) {
tag=ui.draggable;
tag.clone().attr("id", "copy-" + tag.attr("id")).appendTo( this );
},
accept: function(draggable) {
return $(this).find("#copy-" + draggable.attr("id")).length == 0;
}
});