I'm trying to have my dialog auto-close three seconds after opening. I've tried the following methods:
setTimeout($("#mydialog").dialog('close'), 3000);
Here it is in context:
$("#acknowledged-dialog").dialog({
height: 140,
modal: true
});
setTimeout($("#acknowledged-dialog").dialog('close'), 3000);
But with this method, it doesn't even show! I'm guessing the the close method is getting called immediately after it gets shown on the page. The log shows no errors.
I've also tried binding to the dialogopen event:
$("#acknowledged-dialog").bind('dialogopen', function(event, ui) {
setTimeout($(this).dialog('close'), 3000);
});
$("#acknowledged-dialog").dialog({
height: 140,
modal: true
});
The dialog shows, but does not auto-close. No error in the logs here either.
Am I not able to use 'this' in the argument for $ in setTimeout?