如何在jstree中获取所选节点?

时间:2013-10-03 06:04:44

标签: php jquery jstree

我正在使用initial_select&的动态值打开哪个是checked_id。在checked_id中,我已经分配了'"skillTree_1576","skillTree_1573"'值,但它没有工作...如果我静态通过相同的值,那么它的工作正常....以下是源代码

$("#"+node_id+"Edit").live("click", function(){
            $('#'+node_id+'Lookup').show(); 
            $('#'+node_id+'Values').hide(); 
            $("#"+node_id).bind("check_node.jstree", function (e, data) {//check all parent nodes
                var currentNode = data.rslt.obj.attr("id");
                var parentNode =  data.rslt.obj.attr("parent_id");
        $("#"+node_id).jstree("check_node", "#"+parentNode);
            }).bind("uncheck_node.jstree", function (e, data) {//uncheck all child nodes
                var currentNode = data.rslt.obj.attr("id");
                var allChildNodes = data.inst._get_children(data.rslt.obj);
        allChildNodes.each(function(idx, listItem) { 
        var nid = $(listItem).attr("id");
        $("#"+node_id).jstree("uncheck_node", "#" + nid);
            });
        }).jstree({"0":"","plugins":["themes","json_data","ui","search","hotkeys","checkbox"],"checkbox":{
                "real_checkboxes":true,"two_state":true,"checked_parent_open":true,"override_ui":true
            },"themes":{"theme":"classic","dots":true,"icons":false},"json_data":{
                "ajax":{"url":baseUrl+url,"data":function (n) { 
                        return {'node_name': node_id, 'operation' : 'lookup_children', 'id' : n.attr ? n.attr('id').replace(/[a-z0-9A-Z]+_/g,'') : 0 }; 
                        $('#'+node_id+'emptySearch').hide(); },"success":function(){}}},"search":{
                        "show_only_matches":false,"ajax":{
                            "url":baseUrl+url,"data":function (str) {if(str.length > 2 ) { 
                                    return {'node_name': node_id, 'operation' : 'search', 'search_str' : str}; } },"success":function (data) {
                                if(data.length == 0) { $('#'+node_id+'emptySearch').show(); 
                                } else {    
                                    $('#'+node_id+'emptySearch').hide();}}}},"ui":{"initially_select":[checked_id] },"core":{
                                    "initially_open":[checked_id],"load_open":true,"open_parents":true}});
                           // alert ('hello : '+checked_id);
                        });

如果有人对此有所了解,请帮帮我..先谢谢

1 个答案:

答案 0 :(得分:0)

如需选择多个ID,您可以按如下方式使用:

 $("input[id^='skillTree_']")....

^用于以define string开头。

Reference