easyUI combotree 的異步加載

$.post("http://xxxxxxxx.action", {
        "pid" : null
    }, function(json) {

       let mydata = totree(json)

        $('#cc').combotree({
            data:mydata,
            parentField : 'pid',
            required: true,
            onBeforeSelect: function (node) {
                console.log(node)
               
                $.post("http://xxxxxxxx.action", {
                    "pid" : node.id
                }, function(json) {
                    if (node.children && node.children.length){return}
                    var tree = $('#cc').combotree('tree')
                    tree.tree('append', {
                        parentField : 'pid',
                        parent: node.target,
                        data: json
                    });
                    
                    // $("#"+node.target.id).next().show()
                }, "json");

                // debugger;
                if (!$(this).tree('isLeaf', node.target)) {
                    // $(this).combo("showPanel");
                    return false;
                }


            },

        });
    }, "json");

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章