Question

I want to make something happen when back button is pressed so I put this code in my app's .js file:

function wlCommonInit(){            
    // Common initialization code goes here
    WL.App.overrideBackButton(backFunc);
}

function backFunc(){
    alert('You will back to previous page');
}

After building and deploying the application and running it in a device, the alert is shown when I press the Back button.

If I now exit the app by pressing on the Home button and kill the app's process, and then open the app again and press the Back button - it doesn't work.

Was it helpful?

Solution

Place your code INSIDE wlCommonInit(). I suggest to do so in this manner:

function wlCommonInit() {
    WL.App.overrideBackButton(backFunc);      
}

function backFunc() {
    alert('You will back to previous page');
}

Edit: Question updated with the above code snippet and new information based on the comments. Scenario works fine. See comments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top