I am in the process of creating a website demo using Bootstrap 3 to ensure compatibility with IE7/8. The fixed navigation features 4 menu anchors that lead to landing pages for different subjects, each with dropdown menus containing a varying number of sub-menus.
The requirement is for the page to remain static while fetching content from external plain .html pages. I have achieved this by implementing:
$(function(){
$("#submenu a").click(function(e){
e.preventDefault(); //To prevent the default anchor tag behavior
var url = this.href;
$(".container").load(url);
});
});
Issue at Hand
- I am struggling to maintain consistent URLs when refreshing the page using the
location.hash
method. - Clicking on a submenu from the dropdown results in it loading within the same homepage container.
Current Setup
Currently, the homepage contains a navigation bar with menus that have dropdown submenus.
When a Menu link is clicked, it navigates to the corresponding page. This HTML also includes a similar navigation bar, but the active menu href does not have a dropdown; instead, it displays as a new div with nav-pills that trigger the aforementioned load() script upon clicking.
This setup enables the loading of submenu content in the same container if the menu link is shared and specific content needs to be displayed.
Desired Outcome
- Load external MENU.html or SUBMENU.html within the same container on the homepage while updating the URL simultaneously.
- Ensure that sharing the URL leads to opening the page with the specified content.
- When an active menu page is selected, update the navigation to show its submenus in the new div area without the dropdown functionality, maintaining responsiveness with collapsible options if needed.
- Enable reloading the same page with content post browser refresh.
- The ultimate goal is to achieve the following outcomes:
I welcome any feedback, suggestions, sample links, etc. Thank you in advance!
UPDATE: Although I couldn't personally get the code working, I came across a video on Single Page Applications that provides a relevant example of what I aim to achieve...