I am using the following code:
$("#treeview").jstree();
$("#treeview").jstree('open_all');
With the following html:
<div id="treeview">
<ul>
<li>
<a href="#">RTB</a>
<ul>
<li>
<a href="#" onclick="goTo('index.php?module=alarm&pagina=dashboard&id=6',false);">Beneden</a>
</li>
<li>
<a href="#" onclick="goTo('index.php?module=alarm&pagina=dashboard&id=7',false);">Boven</a>
</li>
</ul>
</li>
</ul>
</div>
My problem is that all nodes stay closed, I can’t get them to open with jstree('open_all');.
The jsTree documentation is “sub optimal”. The docs don’t clearly state that the initialization works asynchronously. There’s core.loaded():
This suggests an event
loaded.jstreeis fired after the tree is setup. You can hook into that event to open all your nodes: