Let me start by saying that I specialize in back end development and am facing a specific challenge with building a website that includes two navigation menus. The main navigation menu features links like Home, while the sub-navigation menu includes options such as About Us and Contact Us.
The issue is that the navigation structure changes significantly between the regular view and the bootstrap XS view, necessitating entirely different menu codes for each. My goal is to ensure that the two menus remain in sync so that if a user clicks on a sub-navigation item in one view and then switches to the other view, the correct menu item is still highlighted.
For example, the Home navigation item may have four sub-items in the regular view, but in the XS view, it converts to a dropdown with six sub-items. This requires custom logic to manage properly.
My initial idea is to use the hash in the URL to track the current navigation/sub-navigation selection. When the navigation menu is expanded in the XS view, I can read the hash URL and adjust the highlighting accordingly. Since clicking anywhere will collapse any open sub-menu, expanding the correct sub-menu based on the current selection seems like the most practical approach.
So, what would be the most effective way to address this challenge? While I typically rely on Backbone.js for my single-page applications (SPAs), I'm not sure if it's suitable for this task. Alternatively, there are multiple JavaScript-based solutions or AngularJS might offer a more robust solution to handle these dynamic navigation changes.
While I've developed many SPAs using Backbone.js due to its simplicity for navigation purposes, AngularJS could potentially provide a more comprehensive solution. Any insights or suggestions on how to tackle this issue would be greatly appreciated. I hope this all makes sense, and I apologize for the lengthy description in advance.
Here is some of the relevant code that was requested:
<div class="navbar-left visible-xs LogoLarge" style="margin: 0; padding: 0; margin-top: 1px; text-align: center; margin-left: 87px;">
<a href="#"><img src="~/Images/Logo.gif" height="45" /></a>
<div class="" style="float: right; margin-top: 3px; margin-right: 16px;">
<a class="btn" href="#">
<i class="icon-shopping-cart-white"></i>
</a>
</div>
</div>
<!-- Additional code snippets -->