本文介绍了如何监听jsTree取消选择事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试像下面这样监听JsTree的取消选择事件
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!");
});
});
根据文档此处,"deselect_node"会触发事件,但似乎什么也没有发生当我喜欢上面的时候.我仍然可以收听选择事件.
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.
如何监听jsTree取消选择事件?
How to listen to jsTree deselect event?
推荐答案
对我有用,也许缺少的分号在某些浏览器中已损坏.
Works for me, perhaps the missing semi-colon is breaking in some browsers.
这里将您的示例重写为小提琴: http://jsfiddle.net/mmeah/fyDE6/
Here is re-write of your example as a fiddle:http://jsfiddle.net/mmeah/fyDE6/
已更新: http://jsfiddle.net/mmeah/fyDE6/2/
这篇关于如何监听jsTree取消选择事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!