Reputation: 75
does anybody please know how I should close the dialog with fade effect and reload the page only after it is closed. Unfortunately location.reload occurs immediately without waiting for dialog being closed.
function show_dialog_ok()
{
$("#dialog_ok").text("Your message was sent");
$("#dialog_ok").dialog({
hide: {effect: "fade", duration: 2000}, modal: true
});
setTimeout(function() { $("#dialog_ok").dialog('close'); }, 2000);
location.reload();
}
Upvotes: 0
Views: 254
Reputation: 1498
Use the complete callback to call realod after animation is complete:
function show_dialog_ok()
{
$("#dialog_ok").text("Your message was sent");
$("#dialog_ok").dialog({
hide: {
effect: "fade",
duration: 2000,
complete: function() {
location.reload();
}
}, modal: true
});
setTimeout(function() { $("#dialog_ok").dialog('close'); }, 2000);
}
Upvotes: 0
Reputation: 318352
How about reloading at the same time you're closing the dialog, inside the timeOut
function show_dialog_ok() {
$("#dialog_ok").text("Your message was sent");
$("#dialog_ok").dialog({
hide: {effect: "fade", duration: 2000}, modal: true
});
setTimeout(function() {
$("#dialog_ok").dialog('close');
location.reload();
}, 2000);
}
Upvotes: 1