tree undefined access by id

Hi,

I’m trying to add nodes accessing tree by id but i get an error:

“Cannot read property add undefined”.

(<webix.ui.tree>webix.$$("layersTree")).add(
                {
                    value: layer.Name,
                    id: layer.Id
                },
                -1,
                parent.Id
            );

Thanks

Cannot read property add undefined

Most probably the id of widget ( layersTree ) can be resolved. It can occurs if

  • you are calling this code before the widget was created
  • you have a typo in the widget’s ID
  • the widget is initialized inside of isolated UI