[jQuery] Embedded JavaScript Not Loading With .load() Call
I'm using this code for my website to load pages dynamically:
var hash = window.location.hash.substr(1);
var href = $('#nav li a').each(function(){
var href = $(this).attr('href');
if(hash==href.substr(0,href.length-4)){
var toLoad = hash+'.php #content';
$('#content').load(toLoad)
}
});
$('#nav li a').click(function(){
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('fast',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = $(this).attr('href').substr(0,$(this).attr
('href').length-4);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
It works great. However, I'm using a script for tooltips as well -
when I load a page that has links/abbr's that need tooltips, the
JavaScript doesn't run on them. My solution to this was to add a
<script> in the #content of each page that needed tooltips, except
that doesn't work either.
Can anyone explain this to me? This is a bit frustrating; I may go
back to static pages.