Tau ui list view programatically scroll to top

hello, I have a problem with ui-listview. according to my logic after scroll down the tau list view, I need to automatically scroll to the top after a timeout. but I didn’t see any solution that can programmatically scroll to the top using javascript.

In other words, I need to scroll top and make focus on the first item from any of the last items after a timeout. hope your support, thank you!

1 Like
var listview;

document.getElementById("myPageId").addEventListener("pagebeforecreate", function() {	
	listview = tau.widget.Listview(document.getElementById("myListId"));
});

setTimeout(function() {
	listview.scrollToPosition(0); //INDEX TO SCROLL TO
}, 5000);

I tried this. but unfortunately, nothing happened! do you have any other solution please?
or if we can refresh the relevant page, that also good. actually i just need to reset this page.

I tested it before sending you, it worked with me. I don’t have any other solution, sorry.

as you say, is this automatically scroll to top after 5 seconds? Actually according to your code, i can see only the scroll bar goes to top. but the list exists as same in the last position.

After 5 secs the list scrolls back to the index 0 (first item of the list)… like if someone was scrolling the list back to the start…
If the page is scrolling and the list isn’t, is because you are not “creating/selecting” the list… that’s why the event listener, so before the page is created (and therefore the elements as well) you create the list instance so you have control over it once the page is created… (sorry if it is confusing, English is not my first language…)

Just to be sure… you have to change on the code I sent, the ID that correspondes to the page, and the ID that correspondes to the list… And the event must be “pagebeforecreate” and not “pagebeforeshow”…

can you send me your testing code please? then i can get understand how to do it. if you can mention your email address, it would be help me

That’s all the code I used.