JQM 1.3 Iscrollview 1.3.1

I have a list of links to events using data-iscroll. Each event is also a list (title/date-location/description).

Each time I click on the event list, the event is displayed. If I scroll down the content, when I go back to the event list and then click on another event, the view scrolls to where the previous view was stopped.

I've successfully stopped this by launching an empty() on the event content and then calling updatelayout on the back button of the event content :

$("#bhome").on('vclick', function(e) {

    $('#econt').empty().trigger('updatelayout');

    $.mobile.loading('show');
    e.preventDefault();
    $.mobile.changePage("#page1");
  });

But, of course, android users don't use a back button and use the back key instead.

I've tried to empty() and updatelayout on the pagebeforehide event but apparently, the position is saved before that event happens :

$('#event').on('pagebeforehide', function(event, data) {
    $('#econt').empty();
    $('#econt').trigger('updatelayout');
    $('#escroll').trigger('updatelayout');
});

I've also tried to use the silentscroll function but it's not working either :

$(document).on('pageshow', '#event', function(){
    $.mobile.silentScroll(0);
});

How can I make sure that on viewing a new event, the position is back to the top ?

Here is a snippet of my index.html file :

<div id='container'>
  <div data-role='page' id='page1' data-theme="c" style="background: black;">
</div>
    <div data-iscroll style='background-color:#ddd;'>
      <ul id="el"></ul>
    </div>
<div data-role='footer' data-position='fixed' data-theme="a" data-tap-toggle="false">
</div>
  </div>

  <div data-role="page" id="event" data-theme="c" style="background:black;">
<div data-role='header' data-position='fixed' data-theme="a" style="height:42px;">
      <a id="bhome" class="ui-btn-left ret" data-icon="arrow-l" href="#" data-iconshadow="false">Back</a>
      <h1 id='eh1'></h1>
    </div>
<!--  data-role='content' entraine un scroll horizontal -->
    <div data-iscroll style='background-color:white;' id='escroll'>
      <ul id='econt'></ul>
    </div>
  </div>
有帮助吗?

解决方案

The answer was given by the iscrollview author (works perfectly) :

$("#escroll").iscrollview("scrollTo", 0, 0, 0, false);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top