My problem is a little bit complex.
I have the following code:
$(document).ready(function() {
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-5)){
var toLoad = hash+'.html #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-5);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
Okay, first it's not me who coded it, so I really don't understand what it does and also I tried to change it but i didn't succeed. The code will select a 'nav li' link and display the page in an AJAX way, this mean without reloading it. It does this correctly :) Now, all I want to do it to add a fancybox to register users. To do that I should add the following code.
$("a#reg").fancybox({
'hideOnContentClick': false
});
now I just put the code in $document.readyfunction and the fancy box works as it should, also the nav li links works well. So where's the problem? when I click a 'nav li' link and it load the content and then click again on the the home link, (I return to the first page), the fancy box no longer works. I know it's very sensitive so may be you have bad-understood it, so let me explain it in another way. I have both the selector of the 'nav li' and the selector of the fancy box link, what is the best method to make them works together??
Also can someone explain to me what the code does as well.
Thank you.