本文介绍了JsTree复选框 - 检查事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有这个JsTreeI have this 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 } });我需要分离选择和检查操作,用户必须检查他想要的所有节点但是选择只有一排时间。 现在,当我点击该行的任何地方时,它选择该行并检查该节点,我只需要在用户点击它时选中该复选框。I need to separate the selection and the check action, the user must check all node he wants but select only one row for time.for now when I click everywhere on the row it select that row and check that node, i need to check the checkbox only if the user click on it.我尝试了很多活动,但唯一的工作是:I try so much event but the only that work is:Tree.on("changed.jstree", function (e, data) { });同时捕捉选择和检查的行为。that catch both the action of selection and check.有什么建议吗?推荐答案这个答案是关于jstree的第3版 - 这是你应该在年使用的2016.不幸的是你的示例代码,似乎使用jstree rel 1,我无法帮助你。This answer is about the release 3 of jstree - that is what you should use in year 2016. Unfortunaltely your sample code, seems using jstree rel 1, and I can't help you about that. 对于第3版首先,解开所选状态和复选状态(checkbox.tie_selection:false) - 参见文档First of all, untie the selected and the checked states (checkbox.tie_selection: false) - see the docs然后,使用 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> 这篇关于JsTree复选框 - 检查事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-13 13:58