Where is onBeforeClose?

Dear forum,

Sorry for my first thread if it is a piece of cake but I couldnt find any article about it.

Normally in the previous version (v4.10.10), there used to be “onBeforeClose” event for popups;

But in the newest release (v5.21.2), we don’t have it.

There is a note announces that it’s been removed but without mentioning neither the reason nor the alternatives.

Could you please help, how can we interupt the event of a popup onClose?

Thanks in advance,


You can solve that using a custom button. In v5 you can even assign a keyboard keyCode to activate the button:

var popup = mobiscroll.popup('#mypopup', {
  buttons: [
      text: 'Save',
      keyCode: 'enter',
      handler: function () {
        if (...) {  // check validity

Let me know if this helps!

Hi Hunor, I appreciate your response.

I only want to catch when the user clicks somewhere outside of the popup in order to avoid auto-popup close unintentionally. I want to show a confirm message if they really want to close the popup or not.

Any idea?
Thanks in advance.


This can be done with custom implementation, you need to detect the click outside of the popup, use a confirm to verify the intention and close the popup based on the confirm.

Have you tried returning false in the onClose event?