Created
September 8, 2011 18:21
-
-
Save brianyang/1204180 to your computer and use it in GitHub Desktop.
Single Page Interface Implementation
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
// this function will load the main content from subsequent pages | |
function loadMain(e){ | |
// define a reference to the href val | |
var targetVal = e.currentTarget.attributes[0].nodeValue; | |
// create wrapper elem if needed | |
if (!$('#wrap').length){ | |
$('<div id=wrap />').insertAfter('header'); | |
} | |
// prepare wrapper, pass href target from event obj | |
$('#wrap').empty().load(targetVal + ' #main', function(){ | |
$('#main').fadeIn(2000); | |
}); | |
} | |
// bind events to nav | |
$('header>a').bind('click',function(e){ | |
loadMain(e); | |
e.preventDefault(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment