honestly i think part of your problem is your accordion is not set up correctly. if you look at any of the jquery accordion demo's, and view the source, you'll see that yours isn't anywhere near what they have. now i'm not saying that you cannot achieve
what you are trying
robwscott
Star
8079 Points
1491 Posts
Re: select current page in jquery accordion menu in master page
Apr 24, 2012 05:16 PM|LINK
you want the Menu or SubMenu to open up?
honestly i think part of your problem is your accordion is not set up correctly. if you look at any of the jquery accordion demo's, and view the source, you'll see that yours isn't anywhere near what they have. now i'm not saying that you cannot achieve what you are trying
i think this below if more of the layout you want
<div id="accordion"> <a class="ui-accordion-link acc1" href="#">Menu-1</a> <div> <a id="basicTag" class="ui-accordion-innerlink" href="Link1.aspx">Link1</a><br /> <a class="ui-accordion-innerlink" href="Link2.aspx">Link2</a> </div> <a class="ui-no-accordion" href="Link3.aspx">Menu-2</a> <a class="ui-accordion-link acc1" href="#">Menu-3</a> <div> <ul class="ui-accordion-container" id="acc2"> <li> <a class="ui-accordion-link acc2" href="#">SubMenu-1</a> <div> <a class="ui-accordion-innerlink" href="Link4.aspx">Link4</a><br /> <a class="ui-accordion-innerlink" href="Link5.aspx">Link5</a> </div> </li> <li> <a class="ui-accordion-link acc2" href="#">SubMenu-2</a> <div> <a class="ui-accordion-innerlink" href="Link6.aspx">Link6</a><br /> <a class="ui-accordion-innerlink" href="Link7.aspx">Link7</a> </div> </li> </ul> </div> </div>$(document).ready(function() { $("#accordion").accordion({ collapsible: true, animated: 'slide', autoHeight: false, navigation: true }); function GetCurrentPageName() { var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); return sPage.toLowerCase(); } var thisPage = GetCurrentPageName(); $('#accordion a').each(function() { var href = $(this).attr('href'); if (thisPage == href) { $(this).parent().parent().children('a').addClass('active'); } }); });no i understand that your menu is different, i didn't think your syntax was correct, which is why i made the change to it.
i've made a couple updates to this code since i posted the first time.
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob