Как вы можете видеть, используете ли вы Firebug с демонстрацией, расширение узла запускает запрос GET
для данных:
http://view.jquery.com/trunk/plugins/treeview/demo/source.php?root=36
Ответ только JSON:
[
{
"text": "1. Review of existing structures",
"expanded": true,
"children":
[
{
"text": "1.1 jQuery core"
},
{
"text": "1.2 metaplugins"
}
]
},
{
"text": "2. Wrapper plugins"
},
{
"text": "3. Summary"
},
{
"text": "4. Questions and answers"
}
]
Таким образом, вы могли бы написать действие MVC (однако не используйте .php в URI!)
public JsonResult Source(string root)
{
var model = new object[]
{
new
{
text = "1. Review of existing structures",
expanded = true,
children = new object[]
{
new
{
text = "1.1 jQuery core",
},
new
{
text = "1.2 metaplugins"
}
}
},
new
{
text = "2. Wrapper plugins"
},
new
{
text = "3. Summary"
},
new
{
text = "4. Questions and answers"
}
};
return Json(model);
}
Отсюда должно быть очевидно, как переключаться на основе корневого аргумента.