Last active
August 29, 2015 14:18
-
-
Save DroopyTersen/7c72aa679c1d63e8ea3d to your computer and use it in GitHub Desktop.
Parses SP2010 top menu markup and returns a simplified menu object that outputs clean html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class='cleanmenu'> | |
<li class='menuitem'><a class='menulink' href='/SitePages/Home.aspx'>Root</a></li> | |
<li class='menuitem'><a class='menulink' href='/clients'>Clients</a></li> | |
<li> | |
<ul class='submenu'> | |
<li class='menuitem'><a class='menulink' href='/clients/manitowoc'>Manitowoc</a></li> | |
</ul> | |
</li> | |
<li class='menuitem'><a class='menulink' href='http://google.com'>HeadingNoChildrenNoLink</a></li> | |
<li class='menuitem'><a class='menulink' href='http://google.com'>Heading with Link but no children</a></li> | |
<li class='menuitem'><a class='menulink' href='http://google.com'>Heading 1</a></li> | |
<li> | |
<ul class='submenu'> | |
<li class='menuitem'><a class='menulink' href='http://google.com'>Child Link</a></li> | |
<li class='menuitem'><a class='menulink' href='http://my.skylinetechnologies.com'>Child Link 2</a></li> | |
</ul> | |
</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var menu = spMenuSpider.getMenu(); | |
//Assume we had an empty div in the masterpage with a class of mobile menu | |
//Shove the clean menu html (see the example output) into the empty div | |
$(".mobile-menu").html(menu.toHtml()); | |
//In this example we'd use media queries to hide the normal top nav and show 'mobile-menu' if the user is on a phone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment