Hiding/removing pagination if no results are found in '#hits' - instantsearch.js

I’m trying to remove the pagination widget if no results are found in #hits, right now it just shows ‘nothing found’ together with the 1-page pagination below it. Here’s the code

search.addWidgets([
  instantsearch.widgets.hits({
    container: '#hits',
    templates: {
      empty: 'nothing found'
    }
  }),
  instantsearch.widgets.pagination({
    container: '#pagination', 
    padding:'2'
  }),
]);

note: I’m a beginner please go easy on me

1 Like