views:

69

answers:

1

Here's the jstree code:

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

where treedata contains some Json. Unfortunately, nothing's rendering. The examples I've found are for ajax-loading the Json, but I'm proving the concept with inline Json for now. It's valid Json, but jstree isn't rendering anything at all.

Can anyone tell what I'm doing wrong?

"tree" is a valid <div>

A: 

Is your treedata json or a json string? If it's a json string you need to use var treedata= $.parseJSON(treedatastring); first.

I use this code in a current page and it works. I know you say your json is valid, but you might want to post it anyway or test it at this site

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"]
    });

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

Be sure of your single and double quotation marks, because it makes a big difference.

Regards, Byron Cobb.

Byron Cobb