Skip to content

Instantly share code, notes, and snippets.

@brianyang
Created September 8, 2011 18:21
Show Gist options
  • Save brianyang/1204180 to your computer and use it in GitHub Desktop.
Save brianyang/1204180 to your computer and use it in GitHub Desktop.
Single Page Interface Implementation
// 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