javascript - Laravel生成jstree的json数据

WBOY
Release: 2016-07-06 13:52:12
Original
1174 people have browsed it

laravel从数据库中取出来的数据如何封装成jstree能够读取的模型?如果有能给个实例就好了……

<code>$("#tree_4").jstree({
    core: {
        themes: {
            responsive: !1
        },
        check_callback: !0,
        data: {
            url: function (e) {
                return "{{ route('api.deparment') }}"
            },
            data: function (e) {
                return {
                    parent: e.id
                }
            }
        }
    },
    types: {
        "default": {
            icon: "fa fa-folder icon-state-warning icon-lg"
        },
        file: {
            icon: "fa fa-file icon-state-warning icon-lg"
        }
    },
    state: {
        key: "demo3"
    },
    plugins: ["dnd", "state", "types"]
})</code>
Copy after login
Copy after login

回复内容:

laravel从数据库中取出来的数据如何封装成jstree能够读取的模型?如果有能给个实例就好了……

<code>$("#tree_4").jstree({
    core: {
        themes: {
            responsive: !1
        },
        check_callback: !0,
        data: {
            url: function (e) {
                return "{{ route('api.deparment') }}"
            },
            data: function (e) {
                return {
                    parent: e.id
                }
            }
        }
    },
    types: {
        "default": {
            icon: "fa fa-folder icon-state-warning icon-lg"
        },
        file: {
            icon: "fa fa-file icon-state-warning icon-lg"
        }
    },
    state: {
        key: "demo3"
    },
    plugins: ["dnd", "state", "types"]
})</code>
Copy after login
Copy after login

laravel 查询出的结果 直接进行 toJson() 即可

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!