javascriptjqueryjquery-uimodal-dialogjquery-ui-dialog

jquery-ui-dialog - How to hook into dialog close event


I am using the jquery-ui-dialog plugin

I am looking for way to refresh the page when in some circumstances when the dialog is closed.

Is there a way to capture a close event from the dialog?

I know I can run code when the close button is clicked but that doesn't cover the user closing with escape or the x in the top right corner.


Solution

  • I have found it!

    You can catch the close event using the following code:

     $('div#popup_content').on('dialogclose', function(event) {
         alert('closed');
     });
    

    Obviously I can replace the alert with whatever I need to do.
    Edit: As of Jquery 1.7, the bind() has become on()