Last active
December 20, 2015 04:19
-
-
Save veryrobert/6069967 to your computer and use it in GitHub Desktop.
Jquery Load Content and maintain nav
This file contains hidden or 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
| $('#wrapper').hide(); | |
| //loads content | |
| function loadContent(url) { | |
| $('#wrapper').load(url).delay(500).fadeIn(500); | |
| } | |
| $(function() { | |
| $('#nav a').on('click', function(e) { | |
| e.preventDefault(); | |
| $('#wrapper').fadeOut(500); | |
| var href = $(this).attr("href"); | |
| setTimeout(function(){ | |
| loadContent(href); | |
| history.pushState({}, '', href); | |
| }, 500); | |
| }); | |
| $('#wrapper').on('popstate', function() { | |
| loadContent(location.pathname); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment