如何在jquery jstree中获取已检查的节点 [英] How to get checked nodes in jquery jstree
问题描述
我创建了一个jquery jstree,它运行正常。现在的问题是如何获取已检查节点的详细信息。
I have created one jquery jstree and it's working fine. Now the problem is how to get the the checked nodes details.
用于创建JStree代码为:
For Creating JStree The code is:
$(function () {
$("#tree").jstree({
"json_data" : {
"data" : [
{"data":"pe_opensourcescanning","id":0,"pId":-1,"children": [{"data":"tags","id":30,"pid":0},{"data":"branches","id":29,"pid":0},{"data":"trunk","id":1,"pid":0,"children":[{"data":"import-export","id":28,"pid":1},{"data":"custom_development","id":12,"pid":1},{"data":"Connectors","id":7,"pid":1},{"data":"support","id":6,"pid":1},{"data":"Installation-Configuration","id":5,"pid":1},{"data":"backup","id":2,"pid":1}]}]}
]
},
"plugins" : [ "themes", "json_data", "checkbox", "ui" ]
}).bind("select_node.jstree", function (e, data) { alert(data.rslt.obj.data("id")); });
现在,在获取检查节点时,我需要所有属性值检查元素。比如标签,json对象看起来像{data:tags,id:30,pid:0},所以如果用户选择标签我需要data和id的值。我试图编写一些代码,但遗憾的是这不起作用。
Now while getting checked nodes i need all the attributes values for those checked elements. Say like for "tags" the json object looks like {"data":"tags","id":30,"pid":0}, so if user select tag i need the value of "data" And "id". i have tried to write some code but unfortunately that is not working.
获取已检查的节点。
Getting Checked Nodes.
$("#" +div2.childNodes[i].id).jstree("get_checked",null,true).each
(function () {
alert(this.data);
alert(this.id);
});
请给我一个解决方案。
推荐答案
function submitMe(){
var checked_ids = [];
$("#server_tree").jstree("get_checked",null,true).each
(function () {
checked_ids.push(this.id);
});
doStuff(checked_ids);
查看此次
jstree google groups
这篇关于如何在jquery jstree中获取已检查的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!