简体   繁体   中英

jquery dialog close function

i want when click on close (X) button on dialog do some javascript function . i test some code but no work for me . do like this

$(#dialog).close 
{
function one();
function two();
...
}

tset this and not work :

<script>

  function beh()
  {
  $(document).ready(function() {
    $("#dialog").dialog({
    beforeClose: function(event, ui) {
      alert('hi');
   },
    width: 660,
    height: 495,
    closeOnEscape: false,
    hide: "fadeout",
    resizable: false,
    }
    );
  });
  }
  </script>

You should attach a callback to the beforeclose event like so:

$('#dialog').dialog({
   beforeClose: function(event, ui) {
       //call functions 
       customfunction1();
       customfunction2();
   }
});

then when you close the dialog, it should fire:

$('#dialog').dialog('close');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM