Reputation: 55800
I've added an event listener to my prototype code, and I was wondering if there was a way to check what is observing a given dom element for events?
Preferably inspecting using firebug but javascript code will do.
Upvotes: 0
Views: 97
Reputation: 57197
To the best of my knowledge, there is not. Not in prototype, and not in vanilla JavaScript.
The prototype API is available at http://prototypejs.org/api but having just taken another look to be sure, there does not appear to be any way to do that.
One option for you however, is make a registry of your own.
Edit
for example:
var EventRegistry = function() {
var events=[];
this.addEvent = function (element, func) {
events.push({element:element,func:func});
element.observe(func);
}
this.clearEvents = function(element) {
events = events.reject(function(e) {
if (e.element == element) {
e.element.stopObserving(e.func);
return true;
} else return false;
});
}
this.clearAllEvents = function (element) {
events.each(function(e) { e.element.stopObserving(e.func); });
events = [];
}
}();
(Note: not tested.)
Upvotes: 1