Scroll a view to top

3 posts, 0 answers
  1. Robin
    Robin avatar
    40 posts
    Member since:
    Jul 2012

    Posted 26 Jan 2013 Link to this post

    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. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2894 posts

    Posted 29 Jan 2013 Link to this post

    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!
  3. Daniel Gustavo
    Daniel Gustavo avatar
    1 posts
    Member since:
    Jul 2013

    Posted 29 Aug 2013 Link to this post

    Excelent solution Alexander. It works for me.
Back to Top