-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to asynchronously load #7
Comments
Hi, |
I’m using typescript and rectangular (repository). The data.industryHierarchy contains the array of valid nodes. I’m also using the child array approach (versus the parent id). repositories.industryHierarchy.search($scope.query, IndustryClassification.Any).then(function (data) {
|
If I manually drop in the array, I can see that it supports the parent / child array format. |
my guess is that there is not dirty checking of angular after the promise is resolved, try to update the tree data inside a $timeout or inside $apply, i think that it will solve your problem |
That’s likely. I’ve run into this before… but at the same time, I use the exact same approach to update grids and repeaters and it works just fine.
|
I would also suggest that you initialize the treeData with empty array and just push all the nodes to that array once the promise is resolved, because otherwise you are changing the array reference after the tree was created. |
My same implementation works fine with https://github.com/arvindr21/jsTree-directive https://github.com/arvindr21/jsTree-directive I ported to yours because I need the ability to set the tree instance to a scope variable….
|
Did you try to initialize the array like i suggested? If you still have the problem i would need a way to reproduce it as loading async data works fine for me on my projects. |
If you were to change the scope watcher in you code to look at the array instance versus the array contents, how would you go about it?
|
I think that it will miss the whole point of the binding. You don't want to change the array instance on every new item or updated item in the tree. If you want to replace the whole array content you ca do this with the should-apply method. Set the method to return false before you clear the array, make all the changes in the array, update a version property in the jsTree config object, this will cause the tree to destroyed and created again with the new data |
I have a deliverable and will figure it out tomorrow. Until then, it's angular scope madness. |
Hi, |
I also added async load and tree recreate examples in the demo page of the directive (http://ezraroi.github.io/ngJsTree/). I hope this can help you |
I applied the timeout to the callback and the tree loaded. Thanks! P.S. Do you have any examples for asynchronously loading child nodes on expand? Should I catch the expand event and add them then? |
Hi, yes. This is right way to do this as i see it. Subscribe for the event, and load the data async and add it to the nodes array. |
Thanks again! |
np |
Hello @ezraroi, Do you know if there is a way to configure parent as default to '#'? Thanks! |
hi . im using angularjs and $http service , and have this issue too . any help ? |
I am unable to get the tree to load data from an async promise. Is there a way to force the tree to render once the ng-model has changed?
The text was updated successfully, but these errors were encountered: