I've been trying to figure this one out for some time now, but no luck.
I use simplest jquery and ajax to load content into my page when navigation bar or sidebar links are clicked. I simply put this in document.ready:
$("#nav ul li a").click(function(){content_load($(this).attr('href'));return false;});
My content_load function is this:
function content_load(toLoad)
{
$('#content').hide('fast',loadContent);
function loadContent()
{
$('#content').load(toLoad,'',function(){showNewContent();tb_init('a.thickbox, area.thickbox, input.thickbox');});
}
function showNewContent()
{
$('#content').show('fast');
}
}
This works!
But...when I put simple if...else statement in function_load(), instead of simple ajax load, I get navigated to the page I wanted to load with load() function. It's like "return false" is ignored...
So this is the code that "breaks" everything:
function content_load(toLoad)
{
if(toLoad=="content/page1.html") {//do something}
else
{
$('#content').hide('fast',loadContent);
function loadContent()
{
$('#content').load(toLoad,'',function(){showNewContent();tb_init('a.thickbox, area.thickbox, input.thickbox');});
}
function showNewContent()
{
$('#content').show('fast');
}
}
}
Any idea why???
Thanks! Newman
function_load?