просмотр:
$(document).ready(function() {
$('.tree').click(function () {
$(this).find('ul').slideToggle();
});
});
testArbre
-
@Model.Name
@ShowTree(@Model)
{
- @foreach (var branch in tree.Branch)
{ -
@branch.Name
@if (branch.Branches.Any())
{
@ShowTree(branch)
}
}
Модель:
public class ArbreDroits
{
public string Name { get; set; }
public List Branches { get; set; }
public Tree(string name)
{
Name = name;
Branches = new List();
}
public ArbreDroits AddBranch(string name)
{
Branches.Add(new Tree(name));
return Branches.Last();
}
}
сгенерированный HTML-код выглядит следующим образом:
-
racine
noeud1
noeud1Fils1 -
noeud1Fils2
noeud1Fils2Fils1
noeud1Fils2Fils1Fils1
[*]
noeud1Fils3
[*]
noeud2
Подробнее здесь: https://stackoverflow.com/questions/395 ... is-clicked
Мобильная версия