jquery/jquery-mobile — Issue #3461: silentScroll not working from initPage
Author: mathiaslin
Created: 2012-01-19 11:02:10+00:00
State: open

I want to silently scroll the window when the page is completely loaded, so I call silentScroll inside the initPage listener. However, it doesn't work, no scrolling.

```
$('#mainPage').live( 'pageinit', initPage);

function initPage() {
$.mobile.fixedToolbars.setTouchToggleEnabled(false);
$.mobile.silentScroll(800);
....
```

The only way I can get it to work is to call it via setTimeout, but why? The page should be ready when pageinit is executed, referring to the jqm docs on http://jquerymobile.com/demos/1.0/docs/api/events.html.

With this, automatic scroll works, but it's ugly:

```
setTimeout(function(){$.mobile.silentScroll(8000);}, 1000); // scroll after 1 sec
```

Executing $.mobile.silentScroll(8000); in Firebug / Chrome dev tools also works ok, just not in initPage. When I display an js alert in initPage, it's being shown. But the scrolling is just not being executed properly.