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

Scroll a view to top

2 Answers 327 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 27 Jan 2013, 02:34 AM
Is there a way to scroll the view of the application to the top?

I'm not talking about the Scroller control, but the view itself. My application loads content from the server and displays it using templates. The show_page.html looks something like this:
<div data-role="view" id="page_side" data-show="js_page_side">
    <div id="foo"></div>
    <script id="sidetemplate1" type="text/x-kendo-template">
            <h1>#= overskrift #</h1>
            <p>#= ingress #</p>
            <div class="brodtekst">
            #= brodtekst #
            </div>
    </script>
</div>
<script>
function js_page_side() {
datakilde_sider.query({filter: {field: "id", operator: "eq", value: window['globalvar_vis_side_id'] }});
$("#foo").html(kendo.render(sidetemplate1, datakilde_sider.view()));
//(Here there should be something forcing the view to scroll to top)
}
</script>
It works great, except if the user is viewing a large page, and has scrolled down - then goes back to the menu and selects a new site to view. show_page.html is shown once again, the new content is loaded through the js_page_side() function. It all works - but this new content is now shown already scrolled down to the position the user was before. 

Any ideas?

2 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 29 Jan 2013, 01:11 PM
Hi Robin,

The View uses KendoUI Mobile scroller component to scroll the content. To scroll back to top you can use the reset method. Please try the following:
function js_page_side(e) {
    e.view.scroller.reset(); //reset the scroller
}


Best regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Daniel Gustavo
Top achievements
Rank 1
answered on 30 Aug 2013, 04:48 AM
Excelent solution Alexander. It works for me.
Tags
General Discussions
Asked by
Robin
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Daniel Gustavo
Top achievements
Rank 1
Share this question
or