问题
I am trying to listen to deselect event of JsTree like below
$(document).ready(function() {
var jData = [{
"data": {
"attr": {
"title": "A node"
},
"title" : "A node"
},
"children": [{
"data": {
"title": "child"
},
"children": [{
"data": {
"title": "Grand Child"
}
}]
}]
}];
var myTree = $("#demo1").jstree({
"json_data": {
"data": jData
},
"plugins": ["json_data", "ui", "themeroller"]
});
$(myTree).bind("select_node.jstree", function(evt, data) {
console.log("selected!");
});
$(myTree).bind("deselect_node.jstree", function(evt, data) {
console.log("deselected!");
});
});
According to the documentation here, 'deselect_node' triggers an event, but nothing seems to happen when I do like above. I am able to listen to select event though.
How to listen to jsTree deselect event?
回答1:
Works for me, perhaps the missing semi-colon is breaking in some browsers.
Here is re-write of your example as a fiddle: http://jsfiddle.net/mmeah/fyDE6/
Updated: http://jsfiddle.net/mmeah/fyDE6/2/
来源:https://stackoverflow.com/questions/11576444/how-to-listen-to-jstree-deselect-event