문제

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:

http://jsfiddle.net/RoySutton/hmyJt/5/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top