I tried something like the following but if the page I'm loading has javascript it's not running because the elements are created after page load. When the javascript is something I wrote I simply call the function again after load() and it's ok, but what can I do for the plugins the page has? Like contact forms etc?
Whats is the correct way doing ajax calls in wordpress so as my rest javascript wont brake? Thanks!
$('#subpage_arrows a').live("click", function(){
$('.content_inside').wrap('<div id="ajax_content" />');
$('#ajax_content').css('height',$('.content_inside').height());
var toLoad = $(this).attr('href')+' .content_inside';
$('.content_inside').fadeOut('fast',loadContent);
$('#load').remove();
$('#content').append('<div id="load">Loading...</div>');
$('#load').fadeIn(900);
window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5);
function loadContent() {
$('#ajax_content').load(toLoad,'',showNewContent());
}
function showNewContent() {
$('#ajax_content').hide().fadeIn(1000,hideLoader()).css('height','auto');
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});