OnAfterRender Events issue

Hi Webix Team,
https://webix.com/old-snippet-tool/2ade9b99

In this snippet, If I am recompiling the angular controller and if I am clicking on tree unnecessary onAfterRender event is firing.Because of that my tree is refreshing.
How to solve this issue?

Thanks,
Mira

Hello,

onAfterRender will be called for each component repaint, if multiple items updated it can be called multiple times
This is expected behavior

If you need to call some code after UI was constructed, you can use webix-ready attribute for the directive in question
Check https://webix.com/old-snippet-tool/3a6a08b0

@Nastja ,

I tried your solution but it causes same error.

https://webix.com/old-snippet-tool/b13c8820

If I am clicking on second tree item my onAfterrender event is firing, which refreshes the tree. Please provide me the solution for this.
I got stuck.

Thanks,
Mira

onAfterRender occurs each time when widget repainted.
You can’t change this behavior.
If you need to catch the moment when a component was painted the first time, you can use webix-ready directive

<div webix-ui=“first_config” webix-ready=“doAfterInit(root)”

Also, beware that any change to the scope will trigger the view repainting, which means new onAfterRender call
Making UI as a single entity, instead of using multiple directives will simplify things a lot.