Reputation: 63
I've recently been working on a website where everything was working just fine on localhost but when I moved it to a server the change div function started loading weird and I have no idea why. The bug is more visible when you cycle through portfolio button and contact button.
The website is optimized only for Firefox 9.
This is the script that loads the pages:
$(document).ready(function() {
var hash = window.location.hash.substr(1);
var href = $('.pagination a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad = hash+'.html #content';
$('#content').load(toLoad)
}
});
$('.pagination a').live('click',function() {
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('slow',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load"></span>');
$('#load').fadeIn('slow');
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('slow',hideLoader());
$(window).scrollTop('');
}
function hideLoader() {
$('#load').delay(300).fadeOut('slow');
}
return false;
});
});
Upvotes: 0
Views: 170
Reputation: 6617
You can try the following
When you hide your content and load new content:
$('#content').hide('slow',loadContent);
You should make sure that as soon as it's hidden, the content is made empty:
function loadContent() {
$('#content').empty();
$('#content').load(toLoad,'',showNewContent())
}
Upvotes: 1