I'm using the dynamic page/replacing content technique outlined in this article:
http://css-tricks.com/rethinking-dynamic-page-replacing-content/
However, I'm having trouble with getting other scripts to work. The provided code seems to break all other Javascript (specifically, things like lightbox and some code used for resizing)
Here's the code I'm using from the article.
I have some code that only runs on resize, and that works when the browser is resized. But for some reason the code that should be ran when the site is done loading does not work.
$(function() {
if(Modernizr.history){
var newHash = "",
$mainContent = $("#main-content"),
$pageWrap = $("#page-wrap"),
baseHeight = 0,
$el;
$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();
$("nav").delegate("a", "click", function() {
_link = $(this).attr("href");
history.pushState(null, null, _link);
loadContent(_link);
return false;
});
function loadContent(href){
$mainContent
.find("#guts")
.fadeOut(200, function() {
$mainContent.hide().load(href + " #guts", function() {
$mainContent.fadeIn(200, function() {
$pageWrap.animate({
height: baseHeight + $mainContent.height() + "px"
});
});
$("nav a").removeClass("current");
console.log(href);
$("nav a[href$="+href+"]").addClass("current");
});
});
}
$(window).bind('popstate', function(){
_link = location.pathname.replace(/^.*[\\\/]/, ''); //get filename only
loadContent(_link);
});
} // otherwise, history is not supported, so nothing fancy here.
});