Handling Android back button in jQuery Mobile -


i'm creating jquery mobile app contained within titanium app's webview. when android button pressed, exits app rather going previous page (not best default behavior in opinion.) i'm trying around executing following code on app load:

document.addeventlistener("deviceready", function () {             alert("adding button event");             document.addeventlistener("backbutton", function (e) {                 alert("in button event");                 if ($.mobile.activepage.is('#homepage')) {                     alert("exit app");                     e.preventdefault();                     navigator.app.exitapp();                 }                 else {                     alert("go back");                     navigator.app.backhistory()                 }             }, false);         }, false); 

everywhere see threads issue, use backbutton event, it's not being fired @ all. if wrap in deviceready event, above, deviceready isn't called either. webview somehow suppressing these events, or there way jquery mobile?

your example not work because trying use phonegap api call backbutton handling.

you need use appropriate appcelerator. first should check out cangoback, cangoforward, goback , goforward functions webviews.more info can found here.

basically need create function handle backbutton in webview. this:

detailcontainerwindow.addeventlistener('android:back', function(e){          if (detailview.cangoback()) {             detailview.goback();         } else {             detailcontainerwindow.close();         } }); 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -