views:

221

answers:

1

I have an html like this:

<div id="container1">
    <div class="dragme">drag me</div>
</div>
<div id="container2">
    <div class="dragme">drag me</div>
</div>
<div id="droponme"></div>

$(".dragme").draggable();
$("#droponme").droppable({
    accept: ".dragme",
    drop: function(e, u) { alert( /* find id of the container here*/ ); };
});

I want to find the container of the draggable object on drop event handler. How can I do this?

+1  A: 
$(".dragme").draggable();
$("#droponme").droppable({
    accept: ".dragme",
    drop: function(e, u) {
        alert(u.draggable.parent().attr('id') );
        // in your example: container1 or container2
    }
});
Owen