ezraroi/ngJsTree

Loaded.jstree event handler not always called

Opened this issue · 1 comments

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.

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.