views:

16

answers:

1

Hi, ive downloaded a treeview plugin for jquery (from http://jquery.bassistance.de/treeview/) and ive got a problem with it, because it doesnt generate anything visible.

Ive generated a json string with php:

[{"text": "RSS feed"}, 
 {"text": "Documents", children: [{"text": "test.txt"}]}, 
 {"text": "Todo lists"}]

The jquery code looks like this:

$("#baskets_tree").treeview({collapsed:false,url: "http://localhost/json.php?q=baskets"});

and of course the file contains a list:

<ul id="baskets_tree"></ul>

Everything is loaded, the json code is requested, and nothing changes on the screen. So what could be the problem with this? Any ideas?

A: 

If you're using a new version of jQuery (1.4+) it'll silently fail because your JSON is invalid, check it here: http://www.jsonlint.com/

The issue is that the children property needs double quotes as well, like this:

[{"text": "RSS feed"}, 
 {"text": "Documents", "children": [{"text": "test.txt"}]}, 
 {"text": "Todo lists"}]

I can't say if you have any other issues of course, but that's a sure show stopper and one that needs fixing if you're on jQuery 1.4+, see if that resolve the issue or gets you further along.

Nick Craver