更新:如何在原型中的 DOM 节点上查找事件侦听器?
我正在寻找此问题的更新答案。
似乎在 Prototype 1.6+ 中不再使用 Event.observers(可能是为了避免内存泄漏),那么我现在如何跟踪哪些事件侦听器附加到元素呢?
我知道 Firebug 有一个“下一个中断”按钮,但是在我可以在另一个特定元素上实现我想要的行为之前,body 元素上有几个鼠标侦听器会执行,那么还有其他方法吗?
I'm looking for an updated answer to this question.
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?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已将您链接到的答案更新为更全面的
Prototype
覆盖范围考虑了版本1.6.0
到1.6.1
的变化。中间变得非常混乱,但 1.6.1 有点干净:
I've update the answer you linked to with more comprehensive
Prototype
coverage accounting for changes in versions1.6.0
to1.6.1
.It got very messy in between there, but 1.6.1 is somewhat clean:
现在,事物通过 Element 存储进行路由:)
Element.getStorage(yourElement).get('prototype_event_registry')
将为您提供 Prototype 的Hash
实例,因此您可以执行任何操作你会用哈希来做。请注意,这些是未记录的内部详细信息,将来可能会更改,因此除了调试目的之外,我不会依赖它们。
Things are now routed through Element storage : )
Element.getStorage(yourElement).get('prototype_event_registry')
will give you an instance of Prototype'sHash
, so you can do anything that you would do with hash.Note that these are undocumented internal details which might be changed in the future, so I wouldn't rely on them except for, perhaps, debugging purposes.