lastscroll doesn't work
Agreed. The scrollback function seems to be broken in beta 1 / latest:
Scroll down, tap Next Page, then tap the browser Back button to return to the first page.
Expected behaviour: JQM scrolls the page down to the Next Page link.
Actual behaviour: The user is returned to the top of the first page.
This is on iPhone 4 / iOS 4.3.3.
The scrollback works on 1.0a4.1.
From what it appears... if you create a button instead of a standard link, the last scroll functionality works fine (in my testing environment of Firefox), but if you create a standard link, last scroll does not work properly.
I've been trying to dig through the code to debug this further, but at first glance it's a bit overwhelming.
Well, it appears that a button works because it has the .ui-btn class attached to it. A silly test of adding the ui-btn class to any standard link makes that link work. As for an immediate fix, I simply changed this line:
$activeClickedLink = $link.closest( ".ui-btn" );
... to ...
$activeClickedLink = $link.closest( "a" );
I'm not sure if that's what was intended, but for me, it appears to be doing the job.
Hopefully one final update to this... a better selector would probably be:
$activeClickedLink = $link.closest( ".ui-btn, .ui-link" );
That will probably be closer to what was intended.
@jasonaward : That looks like a good fix to me!
Thanks! I'll take a look and try and get this (or another) fix in for b2.
So, lastScroll no longer works primarily because we stored the lastScroll data on the page element, which is now removed after pagehide. Also, storing a reference to $activeClickedLink as shown above will simply leak memory on most pages (aside from returning to home), since a page and its child elements are removed from the DOM on pagehide.
I've started a branch (https://github.com/jquery/jquery-mobile/tree/last-scroll) with one commit that does the following.
The diff is here: https://github.com/jquery/jquery-mobile/compare/last-scroll
Feedback is much appreciated. thanks!
Scott - should we merge in this branch? Been a while and no word from anyone on this ticket.
This appears to be working correctly (including the latest changes to the branch from 2 days ago) from our testing.
Let me know if you have any questions before this can be pushed into master. Thanks!
I feel like this is still an issue in IE 7/8. I'm wondering if anyone else has noticed this?
@nareneko - Can you create a jsbin or jsfiddle we can test?
I created a page with a listview of 30 items. If you scroll down to the bottom and click on one of the later items, it will display a dialog. When I click out of the dialog, it should take me back to the last scroll position of the first page of listview items. In IE 7 & 8, it doesn't seem to do this.