我如何限制选择父母的子女数量? 请帮帮我
function buildTree(data) {
var dataJson = JSON.parse(data);
$("#onflycheckboxes").jstree({
"json_data": {
data: dataJson,
},
checkbox: {
real_checkboxes: true,
checked_parent_open: true,
three_state: false
},
"search": {
"case_insensitive": true,
"show_only_matches": true
},
"plugins": ["themes", "json_data", "ui", "checkbox", "search"]
});
}
答案 0 :(得分:1)
对于校验节点,您必须在jstree中使用$("#onflycheckboxes").jstree('get_checked')
function buildTree(data) {
var dataJson = JSON.parse(data);
$("#onflycheckboxes").jstree({
"json_data": {
data: dataJson,
},
checkbox: {
real_checkboxes: true,
checked_parent_open: true,
three_state: false
},
"search": {
"case_insensitive": true,
"show_only_matches": true
},
"plugins": ["themes", "json_data", "ui", "checkbox", "search"]
}).bind("before.jstree", function (e, data) {
if (data.func === "check_node") {
if ($("#onflycheckboxes").jstree('get_checked').length >= numberOfCompanies) {
e.preventDefault();
toastMessage();//your message for show to user can't select any more
return false;
}
}
});;