3

Using Coveo UI and infinite scroll. How can we return user back to same place in search result list? Ex: user scrolls through the results and clicks on a result item to view the article. Is there a way to return the user to same place in search result on click Back button or a hard link to position on the page?

I notice as we scroll the result list, url is not updated.

Any suggestion on how to achieve this?

3

You can write some JavaScript to update the URL as you scroll. You'll also want to update the Coveo Search Results component to have an anchor at each result that corresponds to the URL change.

For example, you can have an anchor on the 25th result called #result25. The JavaScript would set your URL with location.hash based on some calculations fired off by the scroll event. When you click on the result, your URL should be something like /results#result25. When you go back in your browser, it should take you back to that anchor.

  • 1
    This is correct but the numberOfResult option by default will be 10. This means that if I have an anchor on position 35, the browser will never find it. So to complement your answer, you will need to override the numberOfResults to load based on the anchor: developers.coveo.com/display/JsSearchV1/… – Simon Langevin Dec 15 '16 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.