-1

I am developing an Cordova Android application with jQuery mobile. I did override the back button click, but backward navigation is not happening. This is my code:

onBackButtonTap : function(event){
        navigator.app.backHistory();
}

When I press the back button, the call is coming to the above function but the application is not navigating back. Can anyone help me with that?

Anders
  • 8,307
  • 9
  • 56
  • 88

1 Answers1

1

@Dineshchakkravarthi, you need to trap the backbutton event. This link will get you the correct page in the documentation -> Cordova backbutton.

Here is the quik example:

document.addEventListener("backbutton", onBackKeyDown, false);

function onBackKeyDown() {
    // Handle the back button
}
  • i have implemented the backbutton trap. That method is getting triggered when i taps the backbutton. inside that i have used navigator.app.backHistory(). But navigation is not happening. – Dineshchakkravarthi Rajagopal Oct 11 '15 at 03:40
  • hMMM.. that was NOT part of your question. There are bugs in some the webview engines. The reference is not always the same. If you google [backhistory](https://www.google.com/search?q=backhistory), then w2schools says use `window.history.back`. A little further down you will see a BUG: [CordovaSim: Need to implement navigator.app.backHistory](https://issues.jboss.org/browse/JBIDE-15814) that bug is *closed*. Meaning, it is no longer a bug. –  Oct 11 '15 at 04:38
  • If you google [jquery backhistory](https://www.google.com/search?q=jquery+backhistory), then you get [jquery: history.back(1) issue](http://stackoverflow.com/questions/11339781/jquery-history-back1-issue). This may be your answer –  Oct 11 '15 at 04:40