Menu is not redrawn/replaced when webix_ui is used

Hi,

I tried to replace a menu based on http://docs.webix.com/helpers__top_ten_helpers.html#webixui
look for replace any existing object.
however menu does not change, see snippet: http://webix.com/snippet/2c0e6cb4
click “update menu” button.

Thank you

Hello,

Firstly, you should have defined an ID for a toolbar. Unless, there isn’t such view as $$(“toolbar”) in the app.

Secondly, when you replace one view with another one featuring the same ID - an error occurs and view looses this ID. It concerns replacing “navMenu” with “navMenu”. It could be solved by accessing the menu via the toolbar’s children array.

All in all, the replacement function looks like:

function updateMenuItems(menuItems) {
        var menuConfig = createMenuConfig(menuItems,true);
        webix.ui(menuConfig, $$('toolbar'), $$('toolbar').getChildViews()[2]);
}

http://webix.com/snippet/b6cc22a2

Btw, if you don’t define an ID manually, a view gets an auto-generated one. It can be accessed via the view object:

view.config.id

just for pasterity here is the snippet showing update of the menu without replacing the view but redefining data property of config:
http://webix.com/snippet/98a5d980