The jsTree documentation is "sub optimal". The docs don't clearly state that the initialization works asynchronously. There's core.loaded():
A dummy function, whose purpose is only to trigger the loaded event. This event is triggered once after the tree's root nodes are loaded, but before any nodes set in initially_open are opened.
This suggests an event loaded.jstree
is fired after the tree is setup. You can hook into that event to open all your nodes:
var $treeview = $("#treeview");
$treeview
.jstree(options)
.on('loaded.jstree', function() {
$treeview.jstree('open_all');
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…