How to scroll back to the top of a page on click?

0
I want to be able to scroll back to the top of my page by the click of a button. I'm trying to use JS for this, using a function for this that is triggered by an on-click event listener.  Array.from(document.querySelectorAll('.save-btn')).forEach(btn => { btn.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); alert('hello') }) }) The alert with ‘hello’ is being triggered (just to test if anything happens at all), but it doesn't scroll back to the top. I’ve also tried the ‘scrollTo’ method using pure HTML and JS and it does work, so it is a valid function.   Any suggestions on how to tackle this?
asked
4 answers
3

Take a look at the “Scroll To” action in the Web Actions module. You just need to call this from a nanoflow.

https://docs.mendix.com/appstore/modules/web-actions

answered
2

Did you check this: https://docs.mendix.com/appstore/modules/web-actions?

answered
0

Thank you both! I didn't know about those web-actions!

answered
0

what we need to pass in target selector of scroll to reach to the top of the page ?

answered