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 justreturn 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 </ons-dialog> </ons-template> <script> 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!'); event.cancel(); } else { console.log('Bye bye!'); } }); dialog.show(); }); }); </script>
-
@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.
-
Thanks for reporting. Fixed here: gh#1669
-
Thank you very much!
:smile: