【发布时间】:2015-05-13 10:58:24
【问题描述】:
我在用 json 文件(或任何东西)填充这个 jquery treeselect 小部件时遇到问题我是 jquery/javascript 的新手,所以我可能缺少一些基础知识。
我有来自https://github.com/travist/jquery.treeselect.js 的插件,但没有找到如何加载它的示例。
<html>
<head>
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.js"></script>
<script type='text/javascript' src='js/jquery.moreorless.js'></script>
<script type='text/javascript' src='js/jquery.treeselect.js'></script>
<script type='text/javascript' src='js/jquery.chosentree.js'></script>
<link rel='stylesheet' type='text/css' href='css/moreorless.css'/>
<link rel='stylesheet' type='text/css' href='css/treeselect.css'/>
<link rel='stylesheet' type='text/css' href='css/chosen.css'/>
<script type='text/javascript'>
jQuery(function () {
var data1 = ["EVENT1", "EVENT2"];
var data2 = [{
"id": 1,
"name": "A green door"
},
{
"id": 2,
"name": "A blue door"
}
]
$('div.chosentree').chosentree({
width: 200,
deepLoad: true,
default_value: data2, // does not work
load: function (node, callback) {
// What do I put here?
/**
* This would typically call jQuery.ajax to load a new node
* on your server where you would return the tree structure
* for the provided node.
*/
}
});
});
</script>
</head>
<body>
<div class="chosentree"></div>
</body>
</html>
【问题讨论】:
标签: javascript jquery html css json