2

这是jstree代码:

 $("#tree").jstree({
          "json_data": {
              "data": treedata,
              "progressive_render": true
          },
          "plugins": ["themes", "json_data"]
      }); 

其中treedata包含一些 Json。不幸的是,没有任何渲染。我发现的示例是用于 ajax 加载 Json,但我现在用内联 Json 来证明这个概念。它是有效的 Json,但 jstree 根本不渲染任何东西。

谁能告诉我做错了什么?

“树”是有效的<div>

4

1 回答 1

3

你的 treedata json 还是 json 字符串?如果是 json 字符串,则需要先使用var treedata= $.parseJSON(treedatastring);

我在当前页面中使用此代码并且它有效。我知道你说你的 json 是有效的,但你可能还是想发布它或在这个站点上测试它

var jsonConverted = $.parseJSON(jsonData);
    $('#tree').jstree({
        "json_data": {
            "data": jsonConverted
        },
        "themes": {
            "theme": "default",
            "url": "/Content/Styles/Default/themes/default/style.css",
            "dots": false
        },
        "plugins": ["themes", "json_data", "ui", "crrm"]
    });

在哪里jsonData= '[{"attr": { "id": "someid"}, "data": { "title":"SomeTitle", "icon": "/Content/images/FolderIcon.png"}, "children":[]}]';

确保你的单引号和双引号,因为它有很大的不同。

于 2010-09-30T13:48:39.737 回答