{
const queryString = new URLSearchParams(new FormData($refs.filter_form)).toString()
let params = new URLSearchParams(window.location.search)
let sort_by = params.get('sort_by')
loading = true;
fetch('/collections/accessories-1?sort_by=' + sort_by + '&' + queryString)
.then(response => response.text())
.then(data => {
let html_div = document.createElement('div');
html_div.innerHTML = data;
let html_dom = html_div.querySelector('#ProductGridContainer2').innerHTML;
document.querySelector('#ProductGridContainer2').innerHTML = html_dom;
// update url without refreshing the page
history.replaceState(null, null, '?sort_by=' + sort_by + '&' + queryString);
})
.catch(error => console.error('Error:', error))
.finally(() => loading = false);
})"
>