作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个jstree,如下
$('#js-tree').jstree({
'core' : {
'data' : {
'url' : "${pageContext.request.contextPath}/makeTree",
"plugins" : [ "types", "search"],
'data' : function (node) {
return { 'id' : node.id };
}
}
}
});
我想在提交信息时检查所选节点是否是叶节点 -
var selectedLeaves = $("#js-tree").jstree("get_selected");
但这只给了我 id 数组。如何使用 is_leaf 方法从所选节点中过滤我们唯一的叶节点?我引用了这篇文章—— Force user to select only leaf nodes这个解决方案对我来说不起作用。
最佳答案
我自己找到了一个解决方案,使用 get_selected
api 的参数来过滤掉文件夹中的叶子 -
var nodes = $("#js-tree").jstree(true).get_selected("full", true);
$.each(nodes,function(i, node){
if(node.children.length >0){
console.log("not leaf");
}
else{
console.log("leaf");
}
});
如果您有更好的解决方案,请告诉我。
关于jquery - JSTree 检查所选节点是否为叶子或仅叶子可选,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31304533/
我正在尝试用 Swift 编写这段 JavaScript 代码:k_combinations 到目前为止,我在 Swift 中有这个: import Foundation import Cocoa e
我是一名优秀的程序员,十分优秀!