[CMS Filter] Clear a search field once a radio field is selected

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

But it doesn’t work. Any smart way to achieve this?

Hey @webmktg.detas! Can you please share a link?

Hey Luis, sure! Here.

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

  window.onload = () => {
    const filterButtons = document.querySelectorAll('[fs-cmsfilter-field="tag"]');
    const resetLink = document.querySelector('[fs-cmsfilter-element="clear"]');
    filterButtons.forEach((filterButton) => {
      filterButton.addEventListener('click', () => {
1 Like

Awesome! Worked perfectly :slight_smile:

1 Like