jsTree load children by ajax

后端 未结 3 1117
一整个雨季
一整个雨季 2021-02-19 23:27

Code posted below loads root elements for my tree by ajax request. My tree is very large so I can\'t load all items at once so I need to load elements by requesting children f

相关标签:
3条回答
  • 2021-02-20 00:13

    Try this :

    $('#jstree_demo_div').jstree(options).bind("select_node.jstree",function(event, data){
    //Load child node here 
    
    });//or "dbclick.jstree" instead of "select_node.jstree"
    
    0 讨论(0)
  • 2021-02-20 00:15
     $('#jstree_demo_div').jstree({
                "plugins" : ["wholerow", "checkbox"],
                'core' : {
                    'data' : {
                        'url' : "/" + site + "/places/api/tree/list/",
                        'data' : function(node) {
                            return {
                                'id' : node.id
                            };
                        }
                    },
                }
            })
    

    The solution to my problem is that if I want to return children by ajax request I need to return json file which contains:

    "children:" true
    
    0 讨论(0)
  • 2021-02-20 00:25

    If you need to load child node you may try using

    $("#jstree_demo_div").bind("select_node.jstree", function(e, data) {
        $("#jstree_demo_div").jstree('open_node', data.node);
    }
    

    so it would fire an ajax load trigger.

    0 讨论(0)
提交回复
热议问题