0

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

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

问候

4

1 回答 1

1

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

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

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

于 2009-04-07T18:07:27.463 回答