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.
The close() method closes the dialog. Tip: This method is often used together with the show() method.
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()
I believe you can also do it while creating the dialog (copied from a project I did):
dialog = $('#dialog').dialog({ modal: true, autoOpen: false, width: 700, height: 500, minWidth: 700, minHeight: 500, position: ["center", 200], close: CloseFunction, overlay: { opacity: 0.5, background: "black" } });
Note close: CloseFunction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With