{
loading = true;
fetch($event.detail.new_url)
.then(response => response.text())
.then(data => {
let html_div = document.createElement('div');
html_div.innerHTML = data;
const button = document.querySelector('#product_pagination .button');
const href = button.getAttribute('href');
const url = new URL(href, window.location.origin);
const pageValue = url.searchParams.get('page');
if(pageValue && parseInt(pageValue) === parseInt(button.getAttribute('data-total-pages'))) {
document.querySelector('#product_pagination').style.display = 'none';
}
let html_dom = html_div.querySelector('#product_grid').innerHTML;
document.querySelector('#product_grid').innerHTML += html_dom;
showingProductsCount = document.querySelectorAll('.product-card').length
calculateProgressBarWidth(showingProductsCount)
//document.querySelector('#product_grid').innerHTML = html_dom;
if (html_div.querySelector('#product_pagination')){
let pagination_dom = html_div.querySelector('#product_pagination').innerHTML;
if(document.querySelector('#product_pagination')) {
document.querySelector('#product_pagination').innerHTML = pagination_dom;
}
}
})
.catch(error => console.error('Error:', error))
.finally(() => loading = false);
})
"
>