deselect_node.jstree event is not getting triggered

779 views
Skip to first unread message

Violet Valiev

unread,
Apr 6, 2015, 11:16:51 AM4/6/15
to jst...@googlegroups.com
Hi there,

I need to save some data before the user navigates to a new node, hence, I need to bind to the deselect_node.jstree event. My tree is initialized as follows (I omitted some code that does not seem relevant):


var plugins = ["themes", "ui", "contextmenu", "types", "unique"];
var core_config = {
"multiple": false,
"check_callback": true,
'data': function (node, cb) {
cb(SessionService.getModelAsJson());
}
}


treeDiv = $(sourceDiv);
treeDiv
.jstree({
'plugins': plugins,
'types': types_def,
'contextmenu': contextmenu_def,
'core': core_config
})
.bind('loaded.jstree', function (event, data) {
data.instance.select_node(selectNodeId);
defer.resolve();
})
.bind("deselect_node.jstree", function (event, data) {
$log.log("deselect_node.jstree");
})

.bind("select_node.jstree", function (event, data) {
/* cbMap['onNodeSelect'](
SessionService.getSelectedNode(), data.node);*/
});

Brian Hoffman

unread,
Apr 6, 2015, 6:30:14 PM4/6/15
to jst...@googlegroups.com
Hi,

What happens if you deselect a node programatically?

  var instance $treeContainer.jstree(true);
  instance.select_node(yourNodeId);
  instance.deselect_node(yourNodeId);

Ivan Bozhanov

unread,
Apr 7, 2015, 4:20:11 AM4/7/15
to jst...@googlegroups.com
select_node and deselect_node are more of internal events, you would be better off with changed.jstree - the event data obejct provides a lot of information.
If you still want to use this code - that is fine - just listen for both deselect_node and deselect_all, as selecting another node will not trigger a deselect_node event for each selected node, but a single deselect_all event which will have information about all deselected nodes.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages