Monaca Onsen UI Discord Chat Github Repo

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.