Callback Functions /

almComplete()

The almComplete() callback is a public JavaScript function dispatched after every successful Ajax Load More query. The callback can be used to trigger functions in other JavaScript files, manipulate DOM content, or simply console.log a message for debugging – how you utilize the callback is completely up to you.

Usage Examples

The following callback examples are used to initiate 3rd party scripts after successful ajax requests.

// Easy Table of Contents - (https://wordpress.org/plugins/easy-table-of-contents/)
window.almComplete = function(alm){
	if(ezTOC){
		ezTOC.init();
	}
}

// LuckyWP - Table of Contents (https://wordpress.org/plugins/luckywp-table-of-contents/)
window.almComplete = function(alm){
	if(window.lwptoc){
		window.lwptoc.globalInit();
	}
}


// Contact Form 7 (https://en-ca.wordpress.org/plugins/contact-form-7/)
window.almComplete = function(alm){
   if(wpcf7){
      wpcf7.initForm( $('.wpcf7-form'));
   }
};


// Easy Fancybox (https://wordpress.org/plugins/easy-fancybox/)
window.almComplete = function(alm){
   $(document.body).trigger('post-load');
};


// Add to Any (https://wordpress.org/plugins/add-to-any/)
window.almComplete = function(alm){
	if(window.a2a_config){      
		a2a.init_all("page"); // Trigger AddToAny
	}
}


// Addthis (https://wordpress.org/plugins/addthis/)
window.almComplete = function(alm){
	if(typeof addthis !== 'undefined') {
		addthis.layers.refresh(); 
	}
}


// ShareThis (https://www.sharethis.com/)
window.almComplete = function(alm){
	if (window.stButtons){
		stButtons.locateElements();
	}
};


// Facebook Comments, Like Button, Share etc.
window.almComplete = function(alm){
	FB.XFBML.parse();
};


// Jetpack - Tiled Galleries
window.almComplete = function(alm){
	var base_url = 'http://mywebsite.com';
	$.getScript( base_url + "/wp-content/plugins/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.js" );
});
JavaScript

Do you have an example you think others would find useful?
Submit it using our contact form and you will receive full credit and a link to your website.


« Back to Callback Functions