tags:

views:

126

answers:

1

Hi,

Using YUI, I want to create a menu button, passing in the menu widget instance.

Result is what looks like a menu button, but the menu doesn't show.

test case: http://sandbox.kluger.com/menu_test.html

// key code section:
    var D = YAHOO.util.Dom,
        menu = new YAHOO.widget.Menu(D.generateId(), {lazyload: true});

    menu.addItems(params.menu);

    var t = new YAHOO.widget.Button({
                type: "menu",
               label: params.label,
                menu: menu,
           container: el
    });

Do I need to render the menu before giving it to the Button?

If you want to see the params.menu, check the test case. The params.menu object is correct, it creates a menu when directly supplied to widget.Button. That's tested in the test case.

Any ideas appreciated.

A: 

Yes, you need to render. Add menu.render(document.body); after menu.addItems(params.menu); and it should work fine.

Keith Bentrup
Yup, worked great. Thanks very much.
Larry K