hitesh israni
hitesh israni

Reputation: 1752

Back Button not working in phonegap android

I have a phonegap app where i am using JQM for designing my pages.

The Issue i am facing is that Back Button generated by JQM is not working on android platforms on some cases. it works fine on IOS though

EDIT: It works on Browsers too. So i suspect there may be some issue while using cordova.

I tried following this post and upgraded to cordova 1.8 from 1.7, but this dint solve my problem.

Cases where back button is not working

I have few JQM files that are called from the index page. Back button is not operational on these files. but inside those files there are JQM pages where Back Button does works

Back button is a standard JQM back button

<a data-role="button" data-rel="back">Back</Back>

I am stuck on this since long time.

Can anyone provide some directions?

EDIT:

Just to eliminate any confusion. BackButton event listener(Reference and suggested in the comments) does gets called. But this is device's back button(the physical button). My issues are with JQM's back button i.e back button with data-rel="back"

Upvotes: 2

Views: 4296

Answers (1)

coderslay
coderslay

Reputation: 14370

Without seeing your code i cant help you with your JQM backbutton issue.. Although i can propose a new solution.

You can register a backbutton listener like this

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

then in the onBackClickEvent you can use it like this

function onBackClickEvent {

var currentPageId = $.mobile.activePage.attr('id');

  if(currentpageId == 'home') {
    $.mobile.changePage("#page2",{ transition : "slide"});
  } else {...}
}

Like this you can control the flow of your application. Hope this will help...

Upvotes: 2

Related Questions