Finding out how dialog was closed

Finding out how dialog was closed

Hi everyone,

I guess there's a simple solution to my problem but I just don't see it.

I have a jQuery dialog with two buttons: ok and cancel. Now I want some code to execute ONLY when the dialog was closed by anything other than the "ok" button (escape key, cancel button, X).

Is there a way to get the button that was clicked in the close event?