Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - accessing an item's ID on double click

Tags:

jquery

This should be an easy one, but through all the research I've done on the net I just can't seem to find the solution!

I've currently got a sortable list using .sortable, and then a .bind event with a double click, with the bind event as follows:

$("#controlContainer").sortable({  
   blah blah  
})  
.bind('dblclick', function(event) {  
    alert($(event.eventData).attr('id'));  
});

My issue is the fact that the above doesn't work, I need to get the ID of whichever element has been double clicked, but can't find a way of accessing it.

Anyone with any solution? Would be greatly appreciated.

like image 209
Chris Dixon Avatar asked Jan 20 '23 05:01

Chris Dixon


1 Answers

Try changing event.eventData to event.target.

.bind('dblclick', function(event) {  
    alert($(event.target).attr('id'));  
});
like image 117
Rocket Hazmat Avatar answered Jan 31 '23 11:01

Rocket Hazmat