0

Let there be this piece of code:

$(some selector).on('some event', function(){ ... });

And far away from this code, I need to know, if I already set any handlers on same type of event. How can I achieve this?

tomascapek
  • 841
  • 1
  • 8
  • 20

1 Answers1

0

You can use $._data(element,"events") which will return objects of event handler binded

$._data($(some selector)[0] , "events" );

.data(“events”): jQuery stores its event-related data in a data object named (wait for it) events on each element. This is an internal data structure so in 1.8 this will be removed from the user data name space so it won’t conflict with items of the same name. jQuery’s event data can still be accessed via jQuery._data(element, "events") but be aware that this is an internal data structure that is undocumented and should not be modified.

(From : http://blog.jquery.com/2011/11/08/building-a-slimmer-jquery/)

Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188