Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

My side nav bar will not display the same list items as my parent jquery

Featured Replies

Hello all,

 

I'm currently designing a side nav bar that expands to display six different nav sub menus. When I click on the parent nav bars it works fine, however whenever I click on the sub menus the menu should display the same level but it doesn't, instead, it displays the sub menu of the item I have clicked.

 

As you can see from the code below the 'result' variable holds the 'news-and-events' from the URL, and the 'sub_menu' variable also holds the 'news-and-events', the only difference is the sub_menu variable is stored from another URL where the 'news-and-events' is stored in a different location.

 

For example the 'result' variable reads the top level URL: http:/localhost/sites/mysite/news-and-events

 

Whilst the sub_result variable reads the URL from: http:/localhost/sites/mysite/news-and-events/sub-page

 

As you can see both are read from different levels. I think this is making a difference as the sub level link extracts the UL list items from a lower part of the nested list. I want both to show the same level on the side nav bar. The result variable gets it correct but the sub_result extracts the list from a lower level.

 

here's a snippet of code:

        // get the url
       if(result == 'news-and-events') {
 
            //hide all other lists
           $('#zz13_RootAspMenu li:nth-child(2)').hide();
           $('#zz13_RootAspMenu li:nth-child(3)').hide();
           $('#zz13_RootAspMenu li:nth-child(4)').hide();
           $('#zz13_RootAspMenu li:nth-child(5)').hide();
           $('#zz13_RootAspMenu li:nth-child(6)').hide();
 
        if ( $("#zz13_RootAspMenu li > ul li:nth-child(1)").is(":visible")) {
 
          // List is visible then slide it up
          $("#zz13_RootAspMenu li:nth-child(1) ul li").slideUp();
          $("#zz13_RootAspMenu li:nth-child(2) ul li").slideUp();
          $("#zz13_RootAspMenu li:nth-child(3) ul li").slideUp();
          $("#zz13_RootAspMenu li:nth-child(4) ul li").slideUp();
          $("#zz13_RootAspMenu li:nth-child(5) ul li").slideUp();
          $("#zz13_RootAspMenu li:nth-child(6) ul li").slideUp();
 
        }  else {
          // List is not visible and slide down
          $("#zz13_RootAspMenu li:nth-child(1) ul li").slideDown("slow");
        } 
 
        // get sub menu link
      }else if(sub_result == 'news-and-events') {

          //hide all other menus
         $('#zz13_RootAspMenu li:nth-child(2)').hide();
         $('#zz13_RootAspMenu li:nth-child(3)').hide();
         $('#zz13_RootAspMenu li:nth-child(4)').hide();
         $('#zz13_RootAspMenu li:nth-child(5)').hide();
         $('#zz13_RootAspMenu li:nth-child(6)').hide();
 
         if ( $("#zz13_RootAspMenu li > ul > li:nth-child(1)").is(":visible")) {
 
            // List is visible then slide it up
            $("#zz13_RootAspMenu li:nth-child(1)").slideUp();
            $("#zz13_RootAspMenu li:nth-child(2)").slideUp();
            $("#zz13_RootAspMenu li:nth-child(3)").slideUp();
            $("#zz13_RootAspMenu li:nth-child(4)").slideUp();
            $("#zz13_RootAspMenu li:nth-child(5)").slideUp();
            $("#zz13_RootAspMenu li:nth-child(6)").slideUp();
 
        } else {
            // List is not visible and slide down
            $("#zz13_RootAspMenu li:nth-child(1)").slideDown("slow");
        } 

   }
 
 

can anyone help?

 

Thanks in advance.

Edited by Dredd2000

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.