Intercept Dialog close

Intercept Dialog close


Hi All,
I want to excute a code when the dialog is close.
I can put code after 'OK', and 'Cancel', but when i use the red cross
of the dialog to close it. How can i put code after this event ?
$('#foo').dialog({
width: 650,
height: 300,
buttons: {
'Ok': function() { $(this).dialogClose(); MyFunction(); },
'Cancel': function() { $(this).dialogClose(); MyFunction(); }
} });