abiku
abiku

Reputation: 2246

Jqueryui draggable, how to get handle id from drag function

Have this simple code:

$( "#draggable" ).draggable({ 
    handle: ".dragableHandler", 
    drag: function(e, ui) {}
});

and have 4 images with the class .dragableHandler, and different id each. How inside drag function find the current handle (one of images) id? i can only find the dragable elment info..

Upvotes: 3

Views: 2392

Answers (2)

abiku
abiku

Reputation: 2246

ok, i've found how to find the handle elment id from inside dragable functions (like stop, drag, start). you must use:

$( "#draggable" ).draggable({ 
    handle: ".dragableHandler", 
    start: function(e, ui) {
       alert(e.originalEvent.target.id);
    }
});

Upvotes: 1

Wookai
Wookai

Reputation: 21793

You can access it via the srcElement of the event:

drag: function(e, ui) {
    var id = e.srcElement.id;
    // do what you need...
}

Upvotes: 1

Related Questions