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.

how to cancel the 'ons-back-button' action?

  • HI,how to cancel the ‘ons-back-button’ action?

  • Onsen UI

    @czpae86 You can use prepop event and call event.cancel() to cancel the pop. Otherwise, ons-back-button has a onClick prop that you can use to add custom behavior (document.querySelector('#my-back-button').onClick = function() { ... };).

  • Can someone confirm if this approach should still work. I’ve tried the following but the console.log won’t show so I don’t think the prepop event still exists. For the record it works with a click handler so the object is querying properly.

    page.querySelector('ons-back-button').addEventListener('prepop', function(event){

  • I did come across the note in the api that it can be cancelled with an onclick event handler so it’s a moot point I suppose.