I have a dialog and I would like the user to confirm when they try to close it. In the onBeforeClose event I call a function to display a confirmation dialog and return the result. However, the dialog always closes immediately and then the confirmation is shown after it closes! I have tried several ways to show the confirmation dialog - native JS confirm, your messager, and another library to display confirmations. The same result occurs no matter how I do it. I have also tried putting the onBeforeClose code in the data-options, which makes no difference. So what is the problem here and how do I fix it?
// ConfirmClose is the function where I ask for the confirmation, trying the different methods mentioned above
$('#dlgDataEntry').dialog({onBeforeClose: function() { return(ConfirmClose()) }}); //
$('#dlgDataEntry').dialog('open');