3

I am closing a pop-up dialog and follow I am opening another pop-up like:

$( "#iece" ).popup( "close" );
$( "#popupMatricula" ).popup( "open" );

I also try:

       $(function() {
            $( "#iece" ).bind({
               popupafterclose: function(event, ui) {                         
                    $( "#popupMatricula" ).popup( "open" );
               }
            });              
        });

But the #popupMatricula never opens.

Francisco Q.
  • 177
  • 2
  • 3
  • 10

3 Answers3

7

I have seen, that the popup always needs some delay if not opened directly with a link... see this working example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
    <title>popup</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset= ISO-8859-5">
</head>
<body>

  <div data-role="page" id="myPage">
    <div data-role="content">
      <h1>Popup</h1>
      <div data-role="popup" id="popupBasic">
        <p>This is a completely basic popup, no options set.</p>
      </div>
      <div data-role="popup" id="popupMatricula">
        <p>This is the Matricula popup.</p>
      </div>
    </div>

    <script>
      $(document).bind('pageinit', function() {
        setTimeout(function(){
          $("#popupBasic").popup();
          $("#popupBasic").popup("open");
        }, 100);
        setTimeout(function(){
          $("#popupBasic").popup("close");
        }, 3000);
        setTimeout(function(){
          $("#popupMatricula").popup();
          $("#popupMatricula").popup("open");
        }, 3100);
      });
    </script>
  </div>

</body>
</html>

EDIT: The short delay is necessary for Firefox, but not for Chrome and Android browsers as @Jasper tested here

Community
  • 1
  • 1
Taifun
  • 6,165
  • 17
  • 60
  • 188
4

In newer versions of JQM it is fixed!

for opening a popup you need to first close any open one then bind a opening of the other like this to the popupafterclose event!

    $("#loading_popup").on("popupafterclose", function () {
            //any action you want like opening another popup
            onloadpopupOpen();

    })

Happy coding!

azerafati
  • 18,215
  • 7
  • 67
  • 72
1

To open a other popup while closing the prev. I use the popupafterclose event.

$(".selector").on("popupafterclose", function ()
{
        //any action you want like opening another popup
         setTimeout(function()
         {
            $('#popup').popup('open');
         }, 100);
});

based on Taifun solution

marcel
  • 313
  • 4
  • 10