tags:

views:

198

answers:

1

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

+1  A: 

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.

Tivac