需求:用Jstree插件实现一部刷新节点数据,即每点开一个节点,就向后台请求一次,返回节点的子节点数据,依次,求大神解答,在线等!
JS代码如下:
<div id="tree" class="tree" style="height:100px;"></div>
<script>
    $(function () {
        $('#tree').jstree({
                'core': {
                    "check_callback": true,
                    "thems":{"stripes": true},
                    'data': {
                        'url': 'geographic/getAllInfo/',
                        "dataType" : "json",
                        'data': function (node) {
                            if (node.id === "#") {
                                return {"id": 0};
                            }
                            return {"id": node.id};
                        }
                    }
                },
                'plugins': ["contextmenu","search","changed"]
            });
        $("#tree").jstree('refresh');
    });
</script>
controll层代码:
@RequestMapping(value = "/getAllInfo", produces = "application/json")
    @ResponseBody
    public String getNodeInfo(@RequestParam(value = "id", required = false) int id) {
        List<Map<String, Object>> list = geographicInfoService.getChildrenInfo(id);
        Map<String, Object> map = list.get(0);
        return toJson(list);
    }