I have a jQuery dialog and I need to execute some_code()
when I press Esc or click the Cancel button. The latter is easy to implement, I just add define a property of the buttons
object:
$('#mydialog').dialog({
closeOnEscape: true,
close: function(event, ui) {
//some_code();
$(this).dialog('destroy')
},
buttons: {
"OK": function() {
$(this).dialog("close");
},
"Cancel": function() {
some_code();
$(this).dialog("close");
}
}
});
But how can I execute some_code()
after pressing Esc? This function must not be called clicking the OK button, so I cannot simply place it in the close
event.