How can I Scroll to top

hi, i’m using instantsearch js on rails.

I want to scroll top for every click. I tried, scrollTo: ‘#top’, scrollTo: ‘body’ but it’s not working.
How can I do ?

   search.addWidget(
      instantsearch.widgets.hierarchicalMenu({
        container: '#categories',
        attributes: ['category', 'subcategory'],
        scrollTo: 'body'
      })
    );

Hi @wedressfair,

We don’t provide such option on this widget, the only one that has this option is Pagination. But you don’t need an option to implement this behaviour. You can add a listener on the links that will trigger the scroll.

Here is a very basic example that show how you can do it. Keep in mind that it’s very basic example. It doesn’t handle all the case (for example you can’t click on the bubble). You will need to adapt it to your needs but you got the main idea.

Hope that helps, let me know if you have questions.