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.

Onsen UI v1 and Android hardware button support

  • I am working on an app that will have 2 pages (index.html & error.html). Both pages use a navigation bar. The nav bar is just a “title” bar really on index.html and has a “back” button on error.html. That all works. When user goes to the error.html, I did NOT use the push page feature of the nav bar due to the fact that the “error.html” runs a lot of Javascript and I could get nothing to actually run when it was a “push page”. Now, however, when the user is on the “error.html” screen and hits the Android hardware back button, the app exits. This is not what I really desire. If user is on “error.html” and the hardware back button is hit, I want it to go back to the “index.html” screen. If the user hits the hardware back button while on “index.html” screen, the exit of the app is what I want, so the problem is not there. When I set it so the “error.html” page was a push page, the back button functionality worked as I wanted, but no scripts would run so the page was useless… Any help is appreciated…

  • I forgot to mention, I am using Monaca and not PhoneGap.

  • Onsen UI

    @dustintinsley I wonder how did you push the page without pushPage. If you manually modify the DOM you don’t get animations I guess.

    Anyway, you can overwrite the back button handler of ons-page. Info in the docs here and here.

    I’d of course recommend using pushPage instead. <script> tags won’t work but I guess you can run the code you need in AngularJS controller.

    Also, if you are starting an app now, why don’t you start with Onsen UI 2.0? This version has more features and better support.