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.
Cancel prepop event shows an error
-
Hi,
I’m using onsenui v2.0.4, angular 1 and Chrome. I was trying to cancel the prepop event to show a confirmation dialog, i tested with the next code:app.navi.on('prepop', function(event) { console.log('Inside the prepop event'); event.cancel(); });
Seems like the event is cancelled but the next error is showed in the console:
Any ideas anyone?
Thank you for your help.
-
@nataly_g_ That’s just a rejected promise. Methods in Onsen UI return promises and you can handle them like this:
myNavigator.popPage() .then(function() { console.log('previous page'); }) .catch(function() { console.log('it was canceled'); });
It’s not important since you are the one causing it (it’s not an internal error). If you want to get rid of it just handle it with
catch
. If you are using anons-back-button
, you can overwrite its behavior withonClick
property:document.querySelector('#my-back-button').onClick = function() { document.querySelector('#myNavigator').popPage().catch(function() {}); };
-
Thanks Fran for your help.
I’m using the
ons-back-button
and i tried to overwriteonClick
event as in your example but it doesn’t work. I used the simple code to test:document.querySelector('#backButton').onClick = function() { console.log('Clicking on back button'); }
The
popPage
is done but it didn’t enter in theonClick
function.Do you have any idea? Thanks.
-
@nataly_g_ Just make sure your back button is there and that you are changing the correct back button. If you are using 2.0.x it should work.