Search code examples
jqueryjquery-mobilemobilepageload

jQuery Mobile getting popout to open on page load


I am using the new pop out features for JQM. Launching the popout via a button click is straightforward but how can I get the popout to launch on page load?

JQM docs say you can do initialise the popout via:

$( "#myPopupDiv" ).popup( "open" )

I tried this by using the code below but can't get it to work.

$(document).bind("mobileinit", function(){
$( "#myPopupDiv" ).popup( "open" )
});

Here is a working demo using video in the popout and a button to launch it.

http://jsfiddle.net/fxakH/

If someone could help make this launch on page load it would be much appreciated. Thank you.


Solution

  • I had the same problem and googled a bit. I found that you asked the question on the jQuery-forum as well and got an answer:

    http://forum.jquery.com/topic/launching-popout-on-page-load
    http://jsfiddle.net/fxakH/4/

    For others with the same problem:
    The key seems to be to open the popup during the pageshow event. It works for me.