how to cancel the 'ons-back-button' action?
-
HI,how to cancel the ‘ons-back-button’ action?
-
@czpae86 You can use
prepop
event and callevent.cancel()
to cancel the pop. Otherwise,ons-back-button
has aonClick
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){ console.log('t1'); event.cancel(); });
-
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.