Please someone help. I cannot work out how to load a Dynatree from the server. Instead of getting a tree I get "Load error! (error)" I have read every single part of the documentaion and read hundreds of stackoverflow type answers and still do not understand, so I am hoping someone will just tell me what to do.
This is what I have:
VIEW
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>LoadAjax</title>
<script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.16.js" type="text/javascript"></script>
<script src='../../Scripts/jquery.cookie.js' type="text/javascript"></script>
<link rel='stylesheet' type='text/css' href='../../Content/skin/ui.dynatree.css' />
<script src='../../Scripts/jquery.dynatree.js' type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#tree").dynatree({
initAjax: { url: "/LoadAjax/GetNodes" }
});
});
</script>
</head>
<body>
<div id="tree"></div>
</body>
</html>
CONTROLLER
public ActionResult GetNodes()
{
var n1 = new DynaNode { title = "Node 1", key = "k1", isLazy = false };
var n2 = new DynaNode { title = "Node 2", key = "k2", isLazy = false };
var n3 = new DynaNode { title = "Node 3", key = "k3", isLazy = false };
var nodeArray = new List<DynaNode> {n1, n2, n3};
return Json(nodeArray);
}
CLASS
public class DynaNode
{
public string title { get; set; }
public bool isFolder { get; set; }
public bool isLazy { get; set; }
public string key { get; set; }
}