Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap Submenus opens all sub menus at the same time. #27

Open
pldiguanaman opened this issue Dec 30, 2015 · 2 comments
Open

Bootstrap Submenus opens all sub menus at the same time. #27

pldiguanaman opened this issue Dec 30, 2015 · 2 comments

Comments

@pldiguanaman
Copy link

I have added the bootstrap submenu CSS and JS to get submenus to appear since this is not a mobile web site. Here is the code:
@code
Dim AppMenuController As New Controllers.AppMenuController
Dim AppMenus = AppMenuController.GetAppMenu
Dim AppMenuRoots = AppMenuController.GetAppMenuRoots

For Each Menu In AppMenuRoots

            @:<td>
                @:<div class="dropdown" style="width:100%">

                @:<ul class="nav navbar-nav navbar-left">
                @:<li class="dropdown">
                @:<a href = "#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" style="height:35px">
                @Menu.Title
                @:<span class="caret"></span></a>

    Dim AppMenuItems = AppMenus.Where(Function(x) x.ParentId IsNot Nothing AndAlso x.ParentId = Menu.MenuId).ToList
    If AppMenuItems IsNot Nothing AndAlso AppMenuItems.Count > 0 Then

                @:<ul class="dropdown-menu" role="menu" style="font-size:12px">

        For Each Item In AppMenuItems

            If AppMenuController.HasAccessToAppMenu(Item.AppLevel) Then

                If String.IsNullOrEmpty(Item.URL) Then
                    Dim SubItems = AppMenus.Where(Function(x) x.ParentId IsNot Nothing AndAlso x.ParentId = Item.MenuId).ToList


                                @:<li class="dropdown-submenu" role="menu"  >
                                @:<a href="#">@Item.Title</a>
                                @:<ul class="dropdown-menu" role="menu" style="font-size:10px">


                    For each SItem In SubItems
                        If AppMenuController.HasAccessToAppMenu(SItem.AppLevel) Then

                                        @:<li style="font-size:10px;white-space:nowrap"><a href =@SItem.URL>@SItem.Title</a></li>

                        End If
                    Next

                                @:</ul> 
                                @:</li> 


                Else
                                @:<li style="font-size:10px"><a href =@Item.URL> @Item.Title</a></li>

                End If


            End If

        Next

                    @:</ul>

                End If

               @:</ul> 
             @:</div>
           @:</td>

Next

For Spacers As Integer = 0 To 10

            @:<td>&nbsp;&nbsp;&nbsp;</td>

Next


    End code

All of the sub menus open the second I hover over the top link. I added this to the bootstrap.css to enable the hover to open the link:
.dropdown:hover .dropdown-menu { display: block; }
Any ideas why all the submenus open at once instead of only when I hover over the submenu link?

@vsn4ik
Copy link
Owner

vsn4ik commented Jan 9, 2016

Which version you are using (Bootstrap, Bootstrap-submenu)? How to initialize the Bootstrap-submenu?

@pldiguanaman
Copy link
Author

Both bootstrap and bootstrap-submenu. I finally got it work by adding several more lines in the bootstrap.css file that I found at another web site. Changing the ".dropdown:hover .dropdown-menu " to
".dropdown:hover>.dropdown-menu " made the ultimate difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants