hamed
hamed

Reputation: 8033

How to find executed function name on specific event

I'm using a jQuery plugin in my application and now I need to develop this plugin for my need. At this time, I want to know For example which function call on clicking some buttons. For example, suppose the plugin had produced a <button id="test">Test</button>. I want to catch function that call on click on this button. Is there any way or tools for doing that?

Update:

Based on nanndoj suggested link, probably jQuery._data( elem, "events" ); can solve my problem. But how can I use that method?

Upvotes: 0

Views: 120

Answers (1)

hamed
hamed

Reputation: 8033

I tried this and solved my problem:

$.each($._data($("#elementID")[0], "events"), function(i, event) {
      console.log(i);
      $.each(event, function(j, h) {
           console.log(h.handler);
      });
});

Here is the fiddle link that helped me: http://jsfiddle.net/9n6gh/.

So many thanks to nanndoj for his help.

Upvotes: 1

Related Questions