CMS Slider - Displaying when empty

We are using the CMS slider on our search results page. Previously, if there were no search results, the slider didn’t display. But recently, it seems that there’s a bug with the slider script and it’s not hiding when empty. @Support-Luis is there anything I can do to hide the slider when there are no results? Thanks for your help!

hey @ashley! You can check if the empty element is present on the page and if it is you can hide the slider.

This snippet should do the trick

  window.onload = () => {
    const emptyElement = document.querySelector('[fs-cms-element = "empty"]');
    const sliderElement = document.querySelector('[fs-cmsslider-element="slider"]');
    emptyElement ? ( = 'none') : console.log('items found');

Fab, this is now resolved - thanks @Support-Luis

1 Like