Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery destroy dialog box after x seconds

How can I destroy a dialog box after a certaing amount of seconds?????

This is my code:

<script type="text/javascript">
 $(function() {
  $(".dialog-message").dialog({
   modal: true,
   buttons: {
    Ok: function() {
     $(this).dialog('close');
    }
   }
  });
 });

 </script>
like image 618
user342391 Avatar asked Oct 14 '22 05:10

user342391


1 Answers

$(function() {
var dialog = $(".dialog-message").dialog({
    modal: true,
    buttons: {
        Ok: function() {
            $(this).dialog('close');
        }
    }
});

setTimeout(function(){
    dialog.dialog('destroy');
},5000); // 5 seconds
});
like image 146
PetersenDidIt Avatar answered Oct 18 '22 22:10

PetersenDidIt