calling tree.define("data", data) causes to call twice event handler

Hi,

I tried to implement my own directive w/ treetable.
When I load data via tree.define(“data”, data) it causes call event handler twice of scope.$watch
Here is the snippet: http://webix.com/snippet/169dcdee
You need to click on “Load Data” link.
Inside the code If you comment out “tree.define(“data”, data);” in
var updateTreeData = function(data) {
tree.define(“data”, data);
tree.refresh();
};
You’ll see that “updateTreeData” is not called twice.

Check
http://webix.com/snippet/d0b7321e

The problem was caused by the way how data is loaded in to the treegrid. Both tree and treegrid do modify the loaded data objects, by adding extra markers ( tree levels, open|closed state, etc ), AngularJS detects such modification and calls data loading second time. You can add webix.copy to make a copy of data before loading, so any data modifications will not trigger data reloading.

On side note - you can select Options|InitMode|Angular in the snippet tool to play with Angular based init( default mode is not angular friendly )

Yep, it works. Great.