Phonegap 2.8.0 raising "no method" overrideBackbutton "with angular -mobile-nav

I have a problem with angular -mobile-nav on the very initial page load of the Cordova 2.8 Android project using Ripple Emulator. The error I am getting is:

TypeError: Object #<Object> has no method 'overrideBackbutton' at module.exports.exec (chrome-extension://geelfhphabnejjhdalkjhgipohgpdnoc/ripple.js:40:22917) at backButtonChannel.onHasSubscribersChange (http://localhost:8076/cordova.js:1145:13) at Channel.subscribe (http://localhost:8076/cordova.js:667:49) at HTMLDocument.document.addEventListener (http://localhost:8076/cordova.js:132:34) at null.<anonymous> (http://localhost:8076/components/mobile-nav/mobile-nav.js:11:14) at Channel.fire (http://localhost:8076/cordova.js:709:23) at http://localhost:8076/cordova.js:232:47 

Basically, this is the reason for the mobile-nav.js 11 line:
document.addEventListener("backbutton", function() {

And the error caused by calling cordova.js coming from line 1145:
exec(null, null, "App", "overrideBackbutton", [this.numHandlers == 1]);

Is this a problem you can replicate? Any help would be greatly appreciated.

+4
source share
2 answers

I first encountered this when using Ripple with Phonegap 2.5.0. As you note, on the 1145 line of cordova-2.8.0.js for Android, it is supposed to work on the Android platform, so it calls the built-in function App.overrideBackbutton (), in which Ripple does not have a stub.

Since it only calls this when attaching / detaching the first handler, I worked on this by spoofing Ripple, thinking that there are already more than one handler:

 <html> <head> <script type="text/javascript" charset="utf-8" src="cordova-2.8.0.js"></script> <script type="text/javascript" charset="utf-8" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> _IS_RIPPLE_EMULATOR = $('#tinyhippos-injected').length > 0; function deviceready() { // Make ripple think that a back button handler has already been attached if(_IS_RIPPLE_EMULATOR) cordova.addDocumentEventHandler('backbutton'); document.addEventListener("backbutton", function(){ alert("Pressed back"); }); } document.addEventListener("deviceready", deviceready, true); </script> </head> <body></body> </html> 
+5
source

As with Ripple 0.9.22, this should no longer be a problem, as the App.exitApp and App.overrideBackbutton methods have been added:

https://git-wip-us.apache.org/repos/asf?p=incubator-ripple.git;a=log;h=refs/tags/0.9.22

So, if possible, upgrade to Ripple or apply the workaround mentioned by Dpa99c.

+1
source

Source: https://habr.com/ru/post/1487620/


All Articles