Hello,
Hoping someone can provide some help.
I am using Wordpress along with an ajax theme and I am also using an ajax search plugin.
In order to stop the page being reloaded and continue to use ajax when clicking a search result in the ajax search I have been provided with the following code:
let dom_observer = new MutationObserver(function(mutation) {
if ( typeof Pjax != 'undefined' ) {
let newContent = document.querySelector(".asl_r");
let pjax = new Pjax({
cacheBust: false,
elements: "a",
selectors: ["title", "#header nav", "#aside", "#footer", "#content"]
});
pjax.refresh(newContent);
jQuery('.asl_r .item').off('click.body').one('click.body', function(){
document.body.click();
});
}
});
let container = document.documentElement || document.body,
config = { attributes: false, childList: true, subtree: true, characterData: false };
dom_observer.observe(container, config);
This works fine, but I have an issue where if you navigate to a page and then hit the back button in a browser the previous page will load but will start to infinitely reload, without this code I can navigate back fine.
Thanks
What I have tried:
I have tried removing cacheBust but this does not help, if someone with knowledge of js/ajax could provide any advice it would be much appreciated.