views:

21

answers:

1

I'm just starting to use YUI. I'm trying to understand how to subscribe elements to different events. It seems pretty simple. Here's some code that I've been tweaking from Yahoo's examples:

//  "click" event listener for the second Button's Menu instance
var onMenuClick = function (p_sType, p_aArgs) {
    var attributes = { width: { to: 0 } };
    var oEvent = p_aArgs[0],    //  DOM event
        oMenuItem = p_aArgs[1]; //  MenuItem instance that was the 
                                    //  target of the event
    if (oMenuItem) {
        YAHOO.log("[MenuItem Properties] text: " + 
                    oMenuItem.cfg.getProperty("text") + ", value: " + 
                    oMenuItem.value);
    }
};

//  Add a "click" event listener for the Button's Menu
oMenuButton2.getMenu().subscribe("click", onMenuClick);

I've looked and looked, but I can't find any documentation that tells me what my callback should look as it maps to what event. My first frustration was that I couldn't find a list of events; I guessed that all the events in event-simulate were recognized events. But I still don't know what the signature of my callback should be.

Can someone tell me what each callback function should fulfill (in terms of the type of the arguments)? Better yet, where's the documentation for this stuff?

A: 

Here's the documentation for the particular callback you give as an example. I agree with you that the documentation is not intuitively designed.

Jonathan Feinberg