easyui 的 accordion 加 tree

这两个一起用的话,现在$('bq').tree('getChecked');得不到选中的值bq就是手风琴的id
,也是tree的根节点的id
代码如下:

//加载手风琴
 function loadaccordion(){
    jQuery("#RightAccordion").accordion({ //初始化accordion
        fillSpace: true,
        border: true,
        animate: false,
        border: false,
        animate: false
    });
    VeloCity.scriptDo(['node=0'], "webcomponent/roles/menupagelist.html",function(data) {
        $.each(data,function(i, e) { //循环创建手风琴的项
            var id = e.id;
            var bq = "#tree" + id;
            var roleid = -1;    //roleid for loading accordion and tree
            $('#RightAccordion').accordion('add', {
                id:e.id,
                title: e.text,
                content: "<ul id='tree" + id + "'></ul>",
                selected: true,
                iconCls: e.iconCls,
                tools:[{
                    iconCls: 'icon-save',
                    handler:function(){
                        saveRoleModole(bq);
                    }
                }]
            });
            $.parser.parse();
            loadTree(id, bq, roleid);
        });
    });
}
//加载树
function loadTree(id, bq, roleid) {
    var args = [];
    args.push("node=" + id + "");
    args.push("roleid=" + roleid + "");
    VeloCity.scriptDo(args, "webcomponent/roles/menupagelist.html",
    function(data) {
        $(bq).css("display", "block");
        $(bq).tree({  
            animate: true,
            checkbox: true,
            onlyLeafCheck:true,
            data: data, 
            onBeforeExpand: function(node, param) {
                var a = node.rNum - 1;
                loadTree(node.id, bq + ">li:eq(" + a + ") ul", roleid);
            },
            onSelect: function(node) {
             if (node.state == "open") {
                    $(this).tree('expandAll', node.target);
                }
            },
            onClick: function(node) {
                alert(node.id);
                if (node.state == 'closed'){  
                    $(this).tree('expand', node.target);  
                }else if (node.state == 'open'){  
                    $(this).tree('collapse', node.target);  
                }
            },  
        });
    });
}

1个回答

来人帮帮忙啊


Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐