Hello y’all
What I’m trying to do is clear a Search Field if a Radio Field is selected.
I tried putting an invisible link “.clear-button”
<a fs-cmsfilter-clear="content" fs-cmsfilter-element="clear" class="clear-button">clear</a>
and mirror the click with
$('.w-radio').click(function() {
// Trigger a click event on elements with class .clear-button
$('.clear-button').click();
console.log('clicked');
});
But it doesn’t work. Any smart way to achieve this?
Hey @webmktg.detas! Can you please share a link?
hey @webmktg.detas! This can be setup using the Mirror Click Events - Mirror a click from one element to another Attribute where all the radio buttons share the trigger
which will affect one target
.
If you want to do it by code this should help
<script>
window.onload = () => {
const filterButtons = document.querySelectorAll('[fs-cmsfilter-field="tag"]');
const resetLink = document.querySelector('[fs-cmsfilter-element="clear"]');
filterButtons.forEach((filterButton) => {
filterButton.addEventListener('click', () => {
resetLink.click();
});
});
};
</script>
1 Like
Awesome! Worked perfectly 
1 Like