I have a Jstree tree that's loaded with data and is displayed.
If I want to redisplay the same tree with entirely new data from a new data source via AJAX,
do I have to destroy the tree and reattach all the event handlers, or is there
a way to do it (reasonably performant) using jstree.refresh or jstree.redraw?
Currently, we are refreshing the tree when someone clicks on a button (see code below)
which works but requires re-attaching all the event
handlers (and we have a lot of event handlers):
$('#somebutton').on('click', function(event) {
// Clear the current tree
// This call also removes all event handlers for the tree
$('#jst_propl').jstree('destroy');
//Rebuild the tree with new data
$('#jst_propl').jstree({
"core" : {
"check_callback" : true,
"data" : {
'url' : function (node) {
return '/getstuff/@mapobj.id.toString/';
},
'data' : function (node) {
return { 'id' : node.id };
}
}
}
});
});