@jpineda91 It looks like your module.resources_page_link.url.href variable is returning blank. When document.location.href is set to blank it just refreshes the page.
If you're just going to be staying on the same page then I don't think a variable is necessary you could use the location object in javascript instead.
jQuery('select[name="topic"]').on('change',function(){
let topic = jQuery(this).val();
let link = location.protocol + '//' + location.host + location.pathname;
if(topic && topic != 'show-all')) {
document.location.href = link + '?topic={{tag}}' + topic;
} else {
document.location.href = link;
}
});
If this answer solved your question, please mark it as the solution.
@jpineda91 It looks like your module.resources_page_link.url.href variable is returning blank. When document.location.href is set to blank it just refreshes the page.
If you're just going to be staying on the same page then I don't think a variable is necessary you could use the location object in javascript instead.
jQuery('select[name="topic"]').on('change',function(){
let topic = jQuery(this).val();
let link = location.protocol + '//' + location.host + location.pathname;
if(topic && topic != 'show-all')) {
document.location.href = link + '?topic={{tag}}' + topic;
} else {
document.location.href = link;
}
});
If this answer solved your question, please mark it as the solution.
@jpineda91 The value when selecting Show All isn't empty, it's "show-all", so either remove the value from the Show All option or change your if statement to:
Hi @alyssamwilie Thank you so much for your reply! I tried updating the code with your suggestion, but when I click on the Show All option it reloads the page with the same path (?topic=.....)