如何在li HTML MVC锚标记中获取breadcrumbs路径 [英] How to get breadcrumbs path in li HTML MVC anchor tag

查看:95
本文介绍了如何在li HTML MVC锚标记中获取breadcrumbs路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Here is my example:




<ul>
        <li><a href="GrandParent.html">Grand Parent</a>
            <ul>
                <li><a href="Parent.html">Parent</a>
                    <ul>
                        <li><a href="child.html">child</a></li></ul>
                </li>
            </ul>
        </li>
    </ul>





每个li元素旁边都有一个锚标记(未显示i)在代码中,请假设)。



现在,如果从上面的代码中选择值Child,那么我应该得到以下结果Grand Parent / Parent /孩子如果我选择父母,那么我应该得到大父母/父母



所以基本上我想让父母带着所有的孩子



这是我的代码:



every li element has a anchor tag next to it (not shown in the code, please assume that).

Now if a select value "Child" from the above code then i should get the below result "Grand Parent/ Parent / Child" and if i select parent then i should get "Grand Parent / Parent"

So basically the i want to get parent with all its child

Here is my code:

@helper GetTreeView(Abacus_CMS.Models.AbacusModel siteMenu, int parentID)
 {
 var url = new System.Web.Mvc.UrlHelper(Context.Request.RequestContext);
 foreach (var i in siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(parentID)))
 {
         <li>
             @{ var submenu = siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(i.Id)).Count();}
             @if (submenu > 0)
             {

             <li style="margin-left: -6px;">
                 <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-'))})" id="@i.Name.Replace(' ', '-').ToLower()" onclick="GetParents()">
                     <i class="fa fa-chevron-right" aria-hidden="true"style="margin-left: 25px; font-size: 10px;">
                     </i><span class="title" style="margin-left: 0px;">@i.Name</span>
                     <span class="arrow " style="height: 4px;"></span>

                 </a>
                 <ul class="sub-menu">
                     @treeview.GetTreeView(siteMenu, i.Id)
                     @* Recursive  Call for Populate Sub items here*@
                 </ul>
             </li>

             @*<span class="collapse collapsible">&nbsp;</span>*@
             }
             else
             {
                 <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-')) })" style="margin-left: 30px;" id="@i.Name.Replace(' ', '-').ToLower()">

                         @i.Name
                     </a>
                     }

                     </li>

             }
             }



如何将痕迹路径作为文本?


how to Get breadcrumb path as text??

推荐答案

使用jQuery,您可以使用几个代码段: Bootstrap和jQuery breadcrumb代码示例| Bootsnipp.com [ ^ ]



如果你不能这样做,你必须点击元素并遍历其父元素(调用parentElement)并填写一些你完成时将加入的数组。
Use jQuery, there are several snippets you might use: Bootstrap and jQuery breadcrumb Code Examples | Bootsnipp.com[^]

If you cannot do that, you have to take the element clicked and loop through its parents (calling parentElement) and filling some array that you will join when you finish.


这篇关于如何在li HTML MVC锚标记中获取breadcrumbs路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆