IBM工作灯 - 客户端API" overrideBackButton"不工作的第二次 [英] IBM Worklight - client-side API "overrideBackButton" doesn't work the second time

查看:109
本文介绍了IBM工作灯 - 客户端API" overrideBackButton"不工作的第二次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使事情发生时,后退按钮是pressed所以我把这个code。在我的应用程序的.js文件:

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');
}

构建和部署应用程序,并在设备上运行后,警报显示,当我preSS后退按钮。

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

如果我现在退出由pressing应用程序上的主页按钮,杀死应用程序的过程,然后再次打开应用程序和preSS后退按钮 - 这是行不通的。

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.

推荐答案

将code INSIDE wlCommonInit()。我建议这样做以这种方式:

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');
}

修改:问题更新上述code片段,并根据意见的新信息。情景工作正常。见注释。

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

这篇关于IBM工作灯 - 客户端API" overrideBackButton"不工作的第二次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆