jQuery UI dialog - wait until close animation is completed

Go To StackoverFlow.com

1

On my website I have two jQuery UI dialogs. One dialog just shows gif image (working animation). I call it before doing AJAX request. After AJAX request is done, I need to close that first dialog, and show second. I do it like this:

$("#dialog-working").dialog("close");
$("#dialog").dialog("open");

but this obviously isn't working. When I do this, both dialogs are visible for some time.

Because of that, I am searching for a way to open second dialog only after first dialog is close (after his animation has completed). Can you help me ?

Thanks !

2012-04-05 14:57
by xx77aBs


4

Your questin is not very clear. To do something after the dialog closes:

$('#dialog').bind('dialogclose', function(){
    //Do something
});
2012-04-05 15:03
by ilyes kooli


1

Check out the dialog close event.

http://jqueryui.com/demos/dialog/#event-close

2012-04-05 15:03
by Rick


1

Check this

Here:

<div class="demo">
  <div id="dialog">
    <p>This is the default dialog</p>
  </div>
  <div id="opener">Click to open</div>
</div>

And here:

$(document).ready(function() {
$("#dialog").dialog({
    autoOpen: false,
    title: 'My dialog title'
});

$("#dialog").dialog();

/* this one beeing of interest for you */
$( "#dialog" ).dialog({
   beforeClose: function(event, ui) {
       alert("dialog is gonna be closed now");
   }
});

$('#opener').click(function() {
    $("#dialog").dialog('open');       
    return false;
});   

});
2012-04-05 15:26
by lzdt
Ads