Bricks 2.0 - active filters count not working with condition?

Hi bricks team,

Does the new dynamic data {active_filters_count} work with conditions? For example, as shown in the screenshot, if no filter is active, the counter will be hidden

active filter count

In general, is it possible from a coding perspective to make dynamic data like {query_results_count_filter} work with conditions? This will be incredibly efficient.

Unfortunately, Element Condition is meant for PHP lifecycle.

You can insert this JavaScript code inside a code element for that page.

function updateActiveFilterSpans() {
  document.querySelectorAll('span[data-brx-af-count][data-brx-af-dd]').forEach(el => {
    if (el.textContent.trim() === '0') {
      el.classList.add('brx-no-active-filter');
    } else {
      el.classList.remove('brx-no-active-filter');
    }
  });
}

// Run on initial page load
document.addEventListener('DOMContentLoaded', updateActiveFilterSpans);

// Run after Bricks AJAX query results are displayed
document.addEventListener('bricks/ajax/query_result/displayed', updateActiveFilterSpans);

Hi @itchycode, Thanks for sharing the code.

Can we request a new interaction property so that we can use it to show/hide the desired elements based on dynamic data like {active_filters_count} and {query_results_count_filter}?

This will be very, very useful.