views:

303

answers:

2

How can I programmatically close a jQuery UI dialog after some number of seconds?

I figure I need to do something inside

window.setTimeout(function() {
    //Something here....
}, 10000);
A: 

Try $('#idOfYourDialogue').dialog("close");

and see http://docs.jquery.com/UI/Dialog

karim79
Thanks - that seemed to do the trick
Jason
+1  A: 
var xSeconds = 2; // 2 seconds
var myDialog = $('dialog_element').dialog('open');
setTimeout(function() { myDialog.close(); }, Xseconds * 1000);
Duncan Beevers
For what ever reason that didn't wok for me. I went with this instead: $(function() { $("#dialog").dialog(); }); window.setTimeout(function() { $('#dialog').dialog("close"); }, 5000);
Jason