Skip to content

Instantly share code, notes, and snippets.

@iso100
Created November 8, 2012 18:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iso100/4040591 to your computer and use it in GitHub Desktop.
Save iso100/4040591 to your computer and use it in GitHub Desktop.
XHR-loaded megamenu content
HTML Markup:
<ul id="primary-nav" role="navigation">
<li id="nav_home" class="current"><a href="homepage.html">Home</a></li>
<li id="nav_products" class="hasMenu"><a href="overview.html">Products</a><div class="megamenu get-remote-content" data-remote-url="/nav_products.html" style="display:none"></div></li>
<li id="nav_shop"><a href="#">Shop</a></li>
</ul>
Script (requires jQuery):
// Get remote content for all DIVs with .get-remote.content class
// URL to grab grom is in data-remote-url attribute
$('div.get-remote-content').each(function () {
thisContainer = $(this);
remoteURL = thisContainer.data('remote-url');
thisContainer.load(remoteURL);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment