1

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.

Larry K
  • 47,808
  • 15
  • 87
  • 140

1 Answers1

1

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

Keith Bentrup
  • 11,834
  • 7
  • 49
  • 56