jQuery Treeview将无法在异步模式下工作 [英] jQuery treeview wont work in async mode
问题描述
ive从 http://jquery.bassistance.de/treeview/),而我就遇到了问题,因为它不会产生任何可见的东西.
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.
我已经用php生成了一个json字符串:
Ive generated a json string with php:
[{"text": "RSS feed"},
{"text": "Documents", children: [{"text": "test.txt"}]},
{"text": "Todo lists"}]
jquery代码如下:
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>
所有内容均已加载,请求了json代码,并且屏幕上没有任何变化. 那么这可能是什么问题呢?有什么想法吗?
Everything is loaded, the json code is requested, and nothing changes on the screen. So what could be the problem with this? Any ideas?
推荐答案
如果您使用的是jQuery的新版本(1.4+) http ://www.jsonlint.com/
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/
问题在于children
属性也需要双引号,例如:
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"}]
我当然不能说您是否还有其他 other 问题,但这是一个确定的显示限位器,如果您使用的是jQuery 1.4+,则需要修复该问题,看看是否可以解决该问题或让您更进一步.
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.
这篇关于jQuery Treeview将无法在异步模式下工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!