View event listeners - Javascript
Asked Answered
K

3

16

I'm wondering if it is possible to view

1. How many event listeners

2. What type of event listener

On a single web page.

Reason being is because I'm using off(); method.

I'm using this framework, which is basically jQuery but not.

Yeah, I'm using off but the even't isn't removing and and I have a feeling there is more than one eventListener on the element.

If it is not possible with Javascript, it is possible in the browser?

Kolosick answered 22/7, 2013 at 18:53 Comment(0)
F
20

Chrome has some built in tools. If you open up the element inspector, focus on an element, scroll to the bottom of the right hand column (where the CSS/Metrics/etc are), you should see a drop down section that says Event Listeners. This can help some...

Often I find it easier to just add event listeners to some DOM element via the console and seeing if it responds. Or I throw in debuggers in various places (before setting up the listener, and inside the listener's callback). The problems I usually run into is the selector I think exists doesn't or the event gets bound too early and misses the selector.

Fix answered 30/7, 2013 at 3:47 Comment(1)
Excellent, I did not realise that was there and provides lot's of information, Thank You.Kolosick
K
25

A long time passes...

I have found something new in Chrome DevTools.

Simple as this in the console

getEventListeners(yourElement);

Documentation: https://developers.google.com/chrome-developer-tools

Kolosick answered 31/8, 2013 at 9:29 Comment(1)
But where is the actual function definition for whatever is listening. I just see a huge object tree. I want to know what exactly is triggered by the event.Bagel
F
20

Chrome has some built in tools. If you open up the element inspector, focus on an element, scroll to the bottom of the right hand column (where the CSS/Metrics/etc are), you should see a drop down section that says Event Listeners. This can help some...

Often I find it easier to just add event listeners to some DOM element via the console and seeing if it responds. Or I throw in debuggers in various places (before setting up the listener, and inside the listener's callback). The problems I usually run into is the selector I think exists doesn't or the event gets bound too early and misses the selector.

Fix answered 30/7, 2013 at 3:47 Comment(1)
Excellent, I did not realise that was there and provides lot's of information, Thank You.Kolosick
B
1

You can use the Visual Event bookmarklet: http://www.sprymedia.co.uk/article/Visual+Event+2

Benedix answered 29/7, 2013 at 21:36 Comment(1)
There is a chrome extension as well which uses the same code chrome.google.com/webstore/detail/visual-event/…Likewise

© 2022 - 2024 — McMap. All rights reserved.