How to get container of draggable inside drop event?

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?

Answers


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

Need Your Help

fiddler HTTPMethod (GET/PUT/POST/DELETE…) Column

http fiddler

Is there an easy way to add an HTTPMethod (GET/PUT/POST/DELETE...) column to the fiddler display?

Gesture error in uitableview cells

iphone objective-c ios uigesturerecognizer uiswipegesturerecognizer

i have a problem with my GestureRecognizer in UITableViewCell,i have swipe-left and right Gesture, tap-hold for 2 second and pinch Gesture in tableview cell, Swipe-right for next chapter, swipe lef...

Lazy Cartesian product of several Seqs in Scala

scala scala-collections

I implemented a simple method to generate Cartesian product on several Seqs like this: