I am creating the search page for an e-commerce website, where we can search by different facets which creates dynamic URL and I am refreshing views only without refreshing page. Now if user press back and forth button of the browser, I want to reload views only with relevant data without reloading the page. I am using below code to capture back and forth button event But its reloading page automatically.
Is there any way to prevent this page refresh?
window.onpopstate = function (event) {
console.log("pop!");
window.getProducts();
window.getArticles();
event.preventDefault();
event.stopImmediatePropagation();
};