Search code examples
javascripthtmlphonejs

Phonejs toolbar menu text shows twice


Recently, I use the Html5 framework: "phonejs" to develop a mobile project, when I want to make a toolbar menusheet in empty views,

It seems menu text will show up twice in this demo: http://phonejs.devexpress.com/Documentation/ApiReference/Widgets/dxToolbar/Configuration?version=13_2#menuItemRender

I use it like this:

homeToolbarItems = [
    { location: 'menu', text: 'Logout',clickAction:logout },
    { location: 'center', text: 'Subscribe Manage' }
];

and the menu shows 'Logout' twice, what can I do?​


Solution

  • It appears that the menuItemRenderer is triggering twice. Once on initial view and once on click. I was able to remedy this buggy behavior by added a Initialize flag to the first view render. Then if the flag was tripped do not render the menu items again on additional request. Example...

        var menuInit = false;
        var viewModel = {
        menuItemRenderer: function(itemData, itemIndex, itemElement){
            if(menuInit == false){
                itemElement.dxButton({ text: "Execute \"" + itemData.text + "\" action" });
                menuInit = true;
            }
        }}