Reputation: 973
I am building JS tree dynamically.
I am deleting node and when it happens,it is selecting to the above node and "select_node" event is getting triggered.
I want to override the default functionality
$('#treeViewContainer').css("height", 100px);
treeView = $('#treeView1');
treeView.bind('select_node.jstree', function (e, data) {
}
I tried to deselect all immediately after deleting the node,but 'select_node' event is getting triggered.
if ($('#treeViewResults').length != 0)
{
treeView.jstree("delete_node", $('#treeViewResults'));
$('#treeView1').jstree("deselect_all");
}
How to skip 'select_node' event from getting triggered or deselect all nodes immediately after deleting the node before triggering the 'select_node' event.
Please suggest
Upvotes: 3
Views: 9529
Reputation: 111
I am also using jsTree to show folder structure. When user select item in jsTree then a new tab will open in the tab host like visual studio code. Then I need to highlight the jsTree item when user selects a tab again like visual studio code. So have 2 scenarios to complete this functionality
1 - deselect all nodes manually
$("#jsTree").jstree().deselect_all(true);
2 - select the appropriate item manually
$("#jsTree").jstree().select_node('item id');
Upvotes: 8
Reputation: 973
I have set'select_prev_on_delete' property to false which is by default to true.and it solved the problem.
$('#treeViewContainer').css("height", 100px);
treeView = $('#treeView1');
treeView.bind('select_node.jstree', function (e, data) {
})
.jstree({
'json_data': {
"data": treeData
},
'ui': {
"select_limit": 1,
"select_prev_on_delete": false
},
Upvotes: 0