jsTree do ajax request for every parent expanding
i'm using jsTree with json as the datasource from the server.
Why the jsTree do ajax request on every click on a node and even if the node doesn't have children the node is ge开发者_如何学Gotting filled with children from the server(it takes the root data!).
How can I prevent that behavior?
script:
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$(function () {
$("#treeview").jstree({
"json_data": {
"ajax": {
"url": "/Tree/Tree"
}
},
"plugins": ["themes", "json_data"]
});
});
});
</script>
server side:
public class TreeController : Controller
{
//
// GET: /Tree/
public ActionResult Tree()
{
return Json(new jsTreeModel
{
data = "Parent",
att = new JsTreeAttribute { id = 1 },
state = "closed",
children = new List<jsTreeModel> { new jsTreeModel { data = "Child", att = new JsTreeAttribute { id = 1 }, state = "closed" } }
}, JsonRequestBehavior.AllowGet);
}
}
public class jsTreeModel
{
public string data { get; set; }
public JsTreeAttribute att { get; set; }
public string state { get; set; }
public List<jsTreeModel> children { get; set; }
}
public class JsTreeAttribute
{
public int id { get; set; }
}
精彩评论