0

I am building a YUI3 module for my workplace. I construct it like so:

var testMenu1 = new Y.ContextMenu({
    id: 'testmenu1',
    menuItems: {
        opsdb: {
            title: 'empty',
            type: 'opsdb',
            separator: false,
            action: function(e, host) {
                iframe_panel_opsdb(host);
            }
        }
    }
});

I'd like to come in later and change the title based on the hostname I right click on. How can I do that given that testMenu1 does now exist. I can do something like testMenu1.set('id', 'newId') but menuItems.opsdb.title, I cannot figure out how to change that one.

4

1 回答 1

0

您可以使用点表示法访问嵌套属性。

如果 menuitems 是一个属性,那么下面应该做你想做的事。(我不知道ContextMenu的细节)。

testMenu1.set('menuitems.opsdb.title', 'myNewTitle');

更多详细信息:http: //yuilibrary.com/yui/docs/attribute/#subattrs

于 2012-08-26T21:25:02.170 回答