I am trying to dynamically populate a menu in Enyo js. But I couldn't find a proper way to do it. Though I tried combining it with jQuery, I wonder if there is an "Enyo" way of doing it.
{kind: "onyx.MenuDecorator", name: "keymapHolder", components: [
{content: "Default"},
{kind: "onyx.Menu", name: "keymapMenu", components:[
]
}],
}
So I have to fill the components of the "keymapMenu" using a function rather than straightaway putting it inside the widget definition.
You can create menu items dynamically by calling createComponents()
. I've put together a fiddle for you that dynamically adds components to a menu. Note that if you want to clear out old items you'll need to call destroy()
on each item that isn't the scroller for the menu.
See this fiddle: