> For the complete documentation index, see [llms.txt](https://developers.discountninja.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.discountninja.io/discount-ninja-developer-hub/theme-edits/code-edits/product-list-page-plp-and-collections/price/searchanise-search-and-filter.md).

# Searchanise Search & Filter

## Snippet

Add the following snippet inside the `body` element in the `theme.liquid`.

<pre class="language-javascript"><code class="lang-javascript">&#x3C;script>
<strong>    document.addEventListener('Searchanise.AutocompleteUpdated', function() {
</strong>        document.dispatchEvent(new CustomEvent('la:dn:collection:updated'));
    });
    
    document.addEventListener('Searchanise.ResultsUpdated', function() {
        document.dispatchEvent(new CustomEvent('la:dn:collection:updated'));
    });
&#x3C;/script>
</code></pre>

## Alternative, using Loaded event

If the above does not work for you, uou may need to wrap this into the `Searchanise.Loaded` event. \
To do this use the following snippet:

```javascript
<script>
  document.addEventListener('Searchanise.Loaded', function() {
    (function($) {
      $(document).on('Searchanise.AutocompleteUpdated', function(event, input, container) {
        document.dispatchEvent(new CustomEvent('la:dn:collection:updated'));
      });
       $(document).on('Searchanise.ResultsUpdated', function(event, input, container) {
        document.dispatchEvent(new CustomEvent('la:dn:collection:updated'));
      });
    })(window.Searchanise.$);
  });
</script>
```
