I have a website that loads its main content via Ajax, but I have run into a problem with getting any plugins/shortcodes that are in said content to load. The plugins do work fine if I directly load each page via the url bar.
Ajax Code
jQuery(document).ready(function() {
var History = window.History;
if (!History.enabled) {
return false;
}
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){
var State = History.getState();
//History.log(State.data, State.title, State.url);
var goto_url = State.url;
jQuery('.content').load(goto_url+ ' #main').hide().delay(750).fadeIn(1000);
});
jQuery('.main-menu a').click(function(evt){
var href = jQuery(this).attr('href');
History.pushState({}, '', href);
var elementClassName = jQuery(this).attr('class');
jQuery('.main-menu a').removeClass('active');
jQuery('.main-menu a.'+elementClassName).addClass('active');
jQuery('.content').load(href+ ' #main',
function() {
jQuery(this).fadeIn(750);
});
return false;
});
});
I am looking to run page specific shortcodes..
<?php echo do_shortcode('[shortcode goes here]'); ?>
after it's corresponding page is loaded via ajax. I believe the correct solution is to run the scripts in the load functions callback but I am not sure how to do this with shortcodes. If need be, I can get the function being called by each shortcode..
Example Shortcode Function
jQuery(document).ready(function($){ window.dzsp_init("#port0",{
settings_slideshowTime:3
,settings_mode: "masonry"
,title: ""
,design_item_width: ""
,design_item_height: ""
,design_categories_style: "normal"
,design_categories_pos: "top"
,design_pageContent_pos: "top"
,settings_disableCats: "off"
,settings_lightboxlibrary: "zoombox"
,settings_preloadall: "off"
,audioplayer_swflocation: "http://sbmdesigns.net/wp-content/plugins/dzs-portfolio/ap.swf"
,videoplayer_swflocation: "http://sbmdesigns.net/wp-content/plugins/dzs-portfolio/preview.swf"
,disable_itemmeta: "off"
,settings_ajax_loadmoremethod: "button"
,settings_mode_masonry_layout: "masonry"
,design_total_height_full: "off"
,settings_mode_masonry_layout_straightacross_setitemsoncenter: "off"
,design_item_height_same_as_width : "off"})
});