开发者

How do I know how to design my callback function for my event listener in YUI?

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜