ezraroi / ngJsTree

Angular Directive for the famous JS Tree
http://ezraroi.github.io/ngJsTree/
MIT License
270 stars 101 forks source link

Loaded.jstree event handler not always called #111

Open Edminsson opened 7 years ago

Edminsson commented 7 years ago

I have a problem with a loaded.jstree event handler that I use to call the open_all function in jstree. Sometimes it gets called and sometimes not. When I debug I can see that jstree triggers the loaded.jstree event but it seems to me that, since manageEvents is being wrapped in a timeout function, the event is triggered before manageEvents gets called. Hence the event is triggered before the event handler is registered. I've only experienced this in IE11.

Edminsson commented 7 years ago

It's not easy to debug this problem because it behaves differently when I put breakpoints in the code. But by using console.logs in the right places I could confirm that sometimes the loaded.jstree event was triggered before the event handler was registered and sometimes the other way around. Basically you've got two pieces of code that run asynchronously and you can't be sure which one will run first.