0

我正在为initial_select & open 使用动态值,即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);
                        });

如果有人对此有任何想法,请帮助我..在此先感谢

4

1 回答 1

0

要选择多个 id,您可以使用如下:

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

^用于以定义字符串开头。

参考

于 2013-10-03T06:07:48.770 回答