I try to have my dialog automatically close three seconds after opening. I 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 is not even displayed! I assume that the close method is called immediately after it is shown on the page. There are no errors in the log.
I 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 });
A dialog box displays but does not close automatically. There are also no errors in the logs.
Can't I use 'this' in the argument for $ in setTimeout?
daniel0mullins
source share