This is a migrated thread and some comments may be shown as answers.

Always start showing view from top position

1 Answer 107 Views
Application
This is a migrated thread and some comments may be shown as answers.
Yrjo
Top achievements
Rank 1
Yrjo asked on 07 Jan 2013, 01:26 AM
How can prevent my views remember their previous scroll position? If I scroll down in one view, then go to another and back again, the first view starts from the scrolled position. This is a natural way in browsers, but I would like to force my view always start in the top position. I can't figure out how to make this happen.

I tried to add a data-before-show="gotoTop" in my views and then adding in kendo initialization this block function

<script>
var app = new kendo.mobile.Application();
function
gotoTop() { $('body').scrollTop();
}
</script>
but it does not seem to work. I am quite new to Kendo, so I appreciate any suggestions or help, thanks!

1 Answer, 1 is accepted

Sort by
0
Accepted
Kamen Bundev
Telerik team
answered on 07 Jan 2013, 09:59 AM
Hi Yrjo,

You can use the Mobile Scroller's reset method to scroll to the page top on view show or beforeshow - you can obtain the View's Mobile Scroller using e.view.scroller, like this:
function gotoTop(e) {
    e.view.scroller.reset();
}


Greetings,
Kamen Bundev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Application
Asked by
Yrjo
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Share this question
or