更新:如何在原型中的DOM节点上查找事件监听器? [英] Update: How to find event listeners on a DOM node in prototype?

查看:238
本文介绍了更新:如何在原型中的DOM节点上查找事件监听器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找此问题的最新答案

似乎在Prototype 1.6+中不再使用Event.observers(可能是为了避免内存泄漏),所以如何跟踪什么事件侦听器附加到一个元素?

It seems that Event.observers is no longer used (perhaps to avoid memory leaks) in Prototype 1.6+, so how do I track down now what event listeners are attached to an element?

我知道Firebug有一个break on next按钮,但是在我可以获得行为之前,body元素上有几个鼠标监听器我想要另一个特定的元素,还有其他方法吗?

I know Firebug has a "break on next" button, but there are several mouse listeners on the body element that execute before I can get to the behavior that I want on another particular element, so is there some other way?

推荐答案

我已经更新了答案您链接到,更全面的原型覆盖版本 1.6.0 更改为 1.6.1

I've update the answer you linked to with more comprehensive Prototype coverage accounting for changes in versions 1.6.0 to 1.6.1.

它之间很混乱,但1.6.1有点干净:

It got very messy in between there, but 1.6.1 is somewhat clean:

var handler = function() { alert('clicked!') };
$(element).observe('click', handler);

// inspect
var clickEvents = element.getStorage().get('prototype_event_registry').get('click');
clickEvents.each(function(wrapper){
    alert(wrapper.handler) // alerts "function() { alert('clicked!') }"
})

这篇关于更新:如何在原型中的DOM节点上查找事件监听器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆