[英]JsTree checkbox - check event
我有这个JsTree
使用此代码:
var Tree = $("#MyTree");
Tree.jstree({
"core": {
"themes": {
"responsive": false,
"multiple" : false,
},
"data": dataTree
},
"types": {
"default": {
"icon": "icon-lg"
},
"file": {
"icon": "icon-lg"
}
},
"ui": {
"select_limit": 1,
},
"plugins": ["wholerow", "types", "checkbox", "ui", "crrm", "sort"],
"checkbox": {
"three_state": false,
"real_checkboxes": false
}
});
我需要分离选择和检查操作,用户必须检查他想要的所有节点,但只选择一行时间。 现在,当我点击行上的任何地方时,它选择该行并检查该节点,我只需要在用户点击它时选中该复选框。
我尝试了很多活动,但唯一的工作是:
Tree.on("changed.jstree", function (e, data) { });
同时捕捉选择和检查的动作。
有什么建议?
这个答案是关于jstree的第3版 - 这是你应该在2016年使用的。不幸的是你的示例代码,似乎使用jstree rel 1,我无法帮助你。
发布3
首先,解开选中状态和复选状态(checkbox.tie_selection:false) - 查看文档
然后,使用check_node.jstree
事件
工作实例
var data1 = [{ "id": "W", "text": "World", "state": { "opened": true }, "children": [{"text": "Asia"}, {"text": "Africa"}, {"text": "Europe", "state": { "opened": false }, "children": [ "France","Germany","UK" ] }] }]; $('#Tree').jstree({ core: { data: data1, check_callback: false }, checkbox: { three_state : false, // to avoid that fact that checking a node also check others whole_node : false, // to avoid checking the box just clicking the node tie_selection : false // for checking without selecting and selecting without checking }, plugins: ['checkbox'] }) .on("check_node.jstree uncheck_node.jstree", function(e, data) { alert(data.node.id + ' ' + data.node.text + (data.node.state.checked ? ' CHECKED': ' NOT CHECKED')) })
<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" type="text/css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script> <div id="Tree"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.