March 18, 201511 yr 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 March 18, 201511 yr by Dredd2000
Create an account or sign in to comment