jstree select_limit无效。我想设置选择限制只选择3个节点 [英] jstree select_limit not working. I want to set selection limit to select only 3 nodes
本文介绍了jstree select_limit无效。我想设置选择限制只选择3个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的jstree函数在这里。
我设置了'select_limit':3
,但是没有用。当我运行时,我能够选择3个以上的节点,但我需要选择不超过3个节点。
My jstree function is here.
I have set 'select_limit' : 3
, but is not working. when I run, I am able to select more than 3 nodes, but I need to select no more than 3 nodes.
j1("#utree_activity").jstree({
"plugins": ["themes", "html_data", "ui", "crrm", "checkbox"],
"html_data": {
"ajax": {
"url": urlGlobal + "jstrees/activitytree/",
"asynchronous": "false",
"data": function (n) {
return {
id: n.attr ? n.attr("id") : 0,
default_activities: default_activities
};
},
"success": function (gb) {
},
}
},
"ui": {
"select_limit": 3,
},
"cookies": {
cookie_options: {
path: "/"
}
},
"checkbox": {
two_state: true,
real_checkboxes: false
}
});
推荐答案
select_limit
doens't handle复选框你必须滚动你自己的 before.jstree
方法。
select_limit
doens't handle checkbox you must roll your own before.jstree
method.
j1.bind("before.jstree", function (e, data) {
if (data.func === "check_node") {
if (j1.jstree('get_checked').length >= 1) {
e.preventDefault();
return false;
}
}
});
请注意,此代码仅作为示例,并且不处理子节点
Note that this code if for example only, and doesn't handle child nodes
工作小提琴: http://jsfiddle.net/cfb9J/1/
这篇关于jstree select_limit无效。我想设置选择限制只选择3个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文