Callback method
richgcook opened this issue · comments
I'm curious... is there a callback we can use without having to input specific needs into the script?
I've tried hunting around, but I'm keen to add a few callbacks once the ajax method has completed; or better yet, an option beforeAjax and afterAjax.
Thanks,
R
To run stuff code the Ajax load has completed, you could bind to the statechangecomplete event.
I'm also working on a fork of Ajaxify that has callbacks that are fired before and after the ajax load, plus many other changes and additions. https://github.com/prod4ever/ajaxify
Thanks for this, by the way.
I did something like this, which I hope helps others.
function ajaxInit() {
// All the code you want to retrigger
}
// Call myInit when document is ready.
ajaxInit();
// Call myInit again after each AJAX load.
$(window).on('statechangecomplete', function() {
ajaxInit();
// Optionally, do other stuff only after an AJAX load.
});