JQuery - double-click access to item id

It should be easy, but through all the research that I have done online, I just can’t find a solution!

I currently have a sortable list using .sortable, and then a double-click .bind event, with a binding event, as follows:

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

My problem is that the above does not work, I need to get the identifier of which item was double clicked, but cannot find a way to access it.

Anyone with any solution? It would be very grateful.

+4
source share
3 answers

Try changing event.eventData to event.target .

 .bind('dblclick', function(event) { alert($(event.target).attr('id')); }); 
+8
source

Try event.target :

 alert(event.target.id); 

event.data designed to access the data you pass in to bind .

Example:

 .bind('click', {foo: 42}, function(event) { alert(event.data.foo); }); 
+1
source

Try

 alert($(this).attr('id')); 
0
source

Source: https://habr.com/ru/post/1344153/


All Articles