Closed ghost closed 7 years ago
I use breadcrumbs as an indicator of the active path. If you want to assign a css class or change the markup you can customize the views by copying them into your own project
As @joeaudette says, you could change the view with something like that:
if (!Model.HasVisibleChildren(childNode))
{
string active = null;
if(!Model.ShouldAllowView(Model.CurrentNode))
{
if (childNode.Value.Key == Model.CurrentNode.Value.ParentKey)
{
active = " active ";
}
}
}
thanks guys, got it working. I did this:
@if (Model.HasVisibleChildren(Model.RootNode)) {
string active = null;
<ul class="nav navbar-nav" role="menubar">
<li class='nav-item @Model.GetClass(Model.RootNode.Value)' role="menuitem"><a class="nav-link custom-nav-link" href="@Url.Content(Model.AdjustUrl(Model.RootNode))">@Html.Raw(Model.GetIcon(Model.RootNode.Value))@Model.AdjustText(Model.RootNode)</a></li>
@foreach (var node in Model.RootNode.Children) {
if (!Model.ShouldAllowView(node)) { continue; }
if (!Model.HasVisibleChildren(node)) {
<li class='nav-item @Model.GetClass(node.Value)' role="menuitem"><a class="nav-link custom-nav-link" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@Model.AdjustText(node)</a></li>
} else {
foreach (var child in node.Children) {
if (child.Value.EqualsNode(Model.CurrentNode.Value)) {
active = "active";
}
}
<li class='nav-item @Model.GetClass(node.Value, active)' role="menuitem"><a class="nav-link custom-nav-link" href="@Url.Content(Model.AdjustUrl(node))">@Html.Raw(Model.GetIcon(node.Value))@Model.AdjustText(node)</a></li>
}
}
</ul>
}
I have a navigation node like this:
when Employee Search is selected, it takes the user a search view were they can enter a search criteria, on submit the user is redirected to the Search Result view.
Is there any way to keep the Search node .active while in the child node?
Thanks.