this.widgets.category = new YAHOO.widget.Button(this.id + "-category",
{
type: "split",
menu: this.id + "-category-menu"
});
我正在使用上面的代码创建一个yui按钮,之后我更新了菜单中的选项,但菜单无法更新。我可以用什么功能更新菜单?
提前致谢!
答案 0 :(得分:1)
我们经常使用按钮的菜单类型。通常,我们希望从头开始重建所有选项。为此,请尝试以下操作:
// assumes btn is the YAHOO.widget.Button
var menu = btn.getMenu();
// clear existing items
menu.clearContent();
// code to add new menu items using either addItem() or addItems()
menu.addItems([
{ text: "--Not Selected--", value: null },
{ text: "Option 1", value: "1" },
{ text: "Option 2", value: "2" }
]);
// forces menu to render
menu.render();