How to use changePage to open a login dialog on first load?

How to use changePage to open a login dialog on first load?

Have a multi-page site and trying to load a login page when the site is first visited.  However the login page (which is a dialog) pops up for a second and then disappears again and the original page loads.  I want the user to be able to bookmark any of the pages if they want to directly visit one of them instead of the default page but still have the login screen shown.  Am I binding to the wrong event?  Thanks.
  1. $(document).bind("mobileinit", function() {
  2.     $('[data-role="page"]').live("pageshow",function(){doLogin()});
  3. });
  4. function doLogin() {
  5. //do boring stuff
  6. $.mobile.changePage("#loginpage");
  7. }
Sometimes after refreshing the page the popup dialog stays open properly.  This is more likely to happen when a setTimeout is used to launch the changePage event with a delay.  So it seems that the problem is if the changePage event fires too early?

It works on desktop browsers pretty reliably but not on mobile browsers.