qwertymk
qwertymk

Reputation: 35256

How to see what exact events are bound to DOM elements?

I feel I want to do this often but can't because I don't have access to the actual events.

For example (and this is just an example as I can just look at the API instead) I was trying to see how stackoverflow's image uploader works, but when I call $($0).data('events) (or $('form[action="/upload/image"] :submit').data('events') ) I get undefined. Is there any other way to look at the actual functions of certain events?

If so, is there also a way to set breakpoints on those events?

EDIT:

Using Visual Event this is what I see

enter image description here

Upvotes: 2

Views: 185

Answers (2)

Widor
Widor

Reputation: 13275

Personally, I use a mix of Firebug and Visual Event.

EDIT: The event highlights don't always line up perfectly due to positioning.

I managed to find the image submit function here: Visual Event example

Upvotes: 1

Aaron Powell
Aaron Powell

Reputation: 25099

In recent versions of jQuery (from 1.7 onwards) they changes the internal structure of the way events are stored see this blog post.

You can still get at the events but it's done a bit differently:

var events = jQuery._data(element, 'events');

Upvotes: 0

Related Questions