Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

prehide event on ons-dialog with cancelable attribute

  • When I cancel the event of prehide on ons-dialog with cancelable attribute (event.cancel()), it’s be no more cancelable (‘Canceled in prehide event.’ displayed at log).
    How to resume it to be cancelable again?

  • @Moguchan I am a bit confused by your question. Are you saying that after you cancel an event, it no longer fires? If so, are you just wanting to prevent the event from happening or remove the event entirely? To prevent it from happening on a call, you should probably be using preventDefault. You can also just return false dependent upon what you are trying to do.

  • Thank you for your reply.
    I want do like below.
    Click outside the dialog for the first time. -> "Not yet!"
    Click outside the dialog for the second time. -> “Bye bye!”

    But, not dislpayed “bye-bye!” on log.

    <ons-template id="mydialog.html" >
      <ons-dialog cancelable>
        My Dialog
      var app = ons.bootstrap();
      var counter = 0;
      ons.ready(function() {
        var dialog = ons.createDialog('mydialog.html').then(function (dialog) {
          dialog.on('prehide', function (event) {
            if (++counter < 2) {
              console.log('Not yet!');
            } else {
              console.log('Bye bye!');

  • @Moguchan Ok, so after working this for over an hour, I believe there is a bug with the cancel function that is removing the event listener all together. I would post this on the github.

  • Onsen UI

    Thanks for reporting. Fixed here: gh#1669

    frandiox created this issue in OnsenUI/OnsenUI

    closed fix(dialogs): event.cancel() reset. #1669

  • Thank you very much!