YUI:页面加载后在某些事件队列的顶部添加事件?

发布于 2024-07-17 02:02:55 字数 181 浏览 3 评论 0原文

如何在页面加载后将新事件放置在链接到对象的所有附加事件的顶部?

实际上,我有一个手风琴,使用一些 YUI 函数来激活其行为,现在在不修改 YUI 主函数的情况下,我需要一些用于调用 AJAX 例程的新函数。 目前我正在尝试使用 Event.getListeners,但我不知道如何处理返回的对象。

问候

How can I put a new event at the top of all attached events linked to an object just after the page load?

Pratically I have an accordion using some YUI funcs to activate its behavior, now without modifying the YUI main function I need some new functions used to call AJAX routines.
Currently I am trying with Event.getListeners, but I don't know how to treat the returned objects.

Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧人哭 2024-07-24 02:02:55

从 Event.getListeners 获得的响应是​​传递给 Event.addListener 的所有参数。 根据 Event.getListeners 文档,它返回

侦听器。   包含以下字段:    
      type:(字符串)事件的类型    
      fn:(函数)提供给 addListener 的回调    
      obj:(对象)提供给 addListener 的自定义对象    
      adjustment: (boolean|object) 是否调整默认上下文    
      范围:(布尔值)基于调整参数的派生上下文  
      index:(int)它在事件实用程序侦听器缓存中的位置 
  

因此,使用该对象,您可能可以使用 事件删除侦听器。移除监听器 & 然后使用 Event.addListener 按照您想要的顺序重新添加它们。 该对象的属性与 Event.addListener 的参数 1:1 映射,因此不会丢失任何内容。

The responses you get from Event.getListeners is all the arguments passed into the Event.addListener. According to the docs for Event.getListeners it returns

the listener. Contains the following fields:   
    type: (string) the type of event   
    fn: (function) the callback supplied to addListener   
    obj: (object) the custom object supplied to addListener   
    adjust: (boolean|object) whether or not to adjust the default context   
    scope: (boolean) the derived context based on the adjust parameter 
    index: (int) its position in the Event util listener cache

So using that object you can probably just remove the Listeners using Event.removeListener & then re-add them all in the order you want using Event.addListener. The object's properties map 1:1 with the args for Event.addListener so nothing will be lost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文