Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Unable to remove BackButton Event listener Ionic 5

$
0
0

Unable to remove the BackButton Event Listener

Adding EventListener
ngOnInit() {
this.platform.backButton.subscribeWithPriority(9999, () => {
document.addEventListener(
“backbutton”,
function (event) {
event.preventDefault();
event.stopPropagation();
},
false
);
});
}

RemovingEventListner: also tries on onDestroy() and on button Click
ionViewDidLeave(){
document.removeEventListener(
“backbutton”,
function (event) {
event.preventDefault();
event.stopPropagation();
},
false
);
}

ionic info

Ionic:

Ionic CLI : 6.16.3 (C:\Users\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 5.0.7
@angular-devkit/build-angular : 0.901.3
@angular-devkit/schematics : 9.1.3
@angular/cli : 9.1.3
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : android 8.1.0, browser 6.0.0, ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.0, (and 22 other plugins)
Utility:

cordova-res : 0.15.3
native-run : 1.4.0

System:

Android SDK Tools : 26.1.1 (C:\Users\AppData\Local\Android\Sdk)
NodeJS : v14.17.1 (C:\Program Files\nodejs\node.exe)
npm : 6.14.13
OS : Windows 10

What would be the right solution to it ?? Please Let me know…

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>