如何在JSON object 中添加到JStree 插件的children 的href 链接?

How to add href links to the children of the JStree plugin in a JSON object?

我有一个 JSON object 类型:

编号 | Parent |文字 |参考资料

我想在我的树结构中为每个 child 添加一个 HREF link。

我的例子 JSON :

var data = [
            { 'id': '1', 'parent': '#', 'text': 'Greater London', "href" : "#" },
            { 'id': '11', 'parent': '1', 'text': 'Goldsmiths College', 'href': 'http://tf1.fr' },
]

//The tree
$(function () {
            $proceduresTree.jstree({
                'core': {
                    'data': data,

                    "themes": {
                        "icons": true
                    }
                },
                'search': {
                    'show_only_matches': true,
                    'show_only_matches_children': true
                },
                "plugins": ["search", "checkbox"]
            });

            var to = false;
            $('#search').keyup(function () {
                if (to) { clearTimeout(to); }
                to = setTimeout(function () {
                    var v = $('#search').val();
                    $proceduresTree.jstree(true).search(v);
                }, 250);
            });
        });

请将您的 JSON 排列如下:

var data = [
  { 'id': '1', 'parent': '#', 'text': 'Greater London', 'a_attr':{href: '#'} },
  { 'id': '11', 'parent': '1', 'text': 'Goldsmiths College', 'a_attr':{href: 'http://tf1.fr'} }
]

在a_attr中添加的任何属性都会出现在锚标签中。