problem with pageshow-event timing

problem with pageshow-event timing

Hi,

i have a mobile application with different pages in one file. First page is "pageMain":
  1. <div data-role="page" id="pageMain">
  2. ...
  3. </div>

I want to show a dialog before using this page, so I have a second page:

  1. <div data-role="page" id="pageMainTerms">
  2. ...
  3. </div>

Then I have a function to open this second page as a dialog:

  1. function automatedTerms()
  2. {
  3. $.mobile.changePage( '#pageMainTerms', {
  4. transition: "pop",
  5.   role: "dialog"
  6.  } );
  7. }
and start this dialog with using the pageshow event in the body onload:

  1. function onBodyLoad() {
  2.       $("#pageMain").on( "pageshow", automatedTerms() );
  3. }

  4. <body onload="onBodyLoad()">
  5. ...

If I start the site, it shows the dialog for a very short time, then the pageMain is loaded and the dialog is not visible. Is there any possibility to open the dialog AFTER showing the first page?

Thanks!
Sebastian