[英]IBM Worklight 6.0 - WL.Client.reloadApp() not working in Windows Phone 8
We are using Worklight 6.0.0 enterprise edition and currently building hybrid apps for android, BB, Windows Phone 8 and iOS. 我们正在使用Worklight 6.0.0企业版,目前正在为Android,BB,Windows Phone 8和iOS构建混合应用程序。
We are currently getting the below error when invoking WL.Client.reloadApp()
when clicking on a logout button. 当前,单击注销按钮时调用WL.Client.reloadApp()
时,出现以下错误。 This works fine all OSs except for WP8. 除WP8之外,此功能在所有操作系统上均可正常运行。
CordovaBrowser_NavigationFailed :: ///www/default/www/default/pages/www/default/pages/www/default/pages/www/default/pages/myaccount.html ERROR: Exception in InvokeScriptCallback :: An unknown error has occurred. CordovaBrowser_NavigationFailed :: ///www/default/www/default/pages/www/default/pages/www/default/pages/www/default/pages/myaccount.html错误:InvokeScriptCallback中的异常::发生未知错误。 Error: 80020006. ERROR: Exception in InvokeScriptCallback :: An unknown error has occurred. 错误:80020006。错误:InvokeScriptCallback中的异常::发生未知错误。 Error: 80020006. 错误:80020006。
This is our logout function: 这是我们的注销功能:
logout() {
window.localStorage.clear();
$.mobile.changePage("../MainPage.html");
$('#username').val('');
$('#password').val('');
$("#Footer").show();
$("#ui_logoutlst").hide();
$("#homeBt_menu").hide();
$('ul#QuickLinks li').width('50%');
};
Looking at the edited comments and question, the problem could be at the path used. 查看编辑后的评论和问题,问题可能出在所使用的路径上。
Take a look at the multi-page sample project provided in the IBM Worklight Getting Started webpage . 看一下IBM Worklight入门网页中提供的多页样本项目。 It contains special handling for WP8 which you may need to apply to your logout function as well. 它包含对WP8的特殊处理,您可能还需要将其应用于注销功能。
Building a multi-page application training module 构建多页应用程序培训模块
Multi-page sample project 多页样本项目
Note how the path is handled specifically for Windows Phone 8. 请注意如何专门为Windows Phone 8处理路径。
common\\main.js : common \\ main.js :
var path = "";
function wlCommonInit(){
// Special case for Windows Phone 8 only.
if (WL.Client.getEnvironment() == WL.Environment.WINDOWS_PHONE_8) {
path = "/www/default/";
}
...
...
}
You need to now do one of two things: 您现在需要执行以下两项操作之一:
Updated April 8th, 2014 2014年4月8日更新
I have used the sample project you've provided in my previous answer. 我使用了您在上一个答案中提供的示例项目 。
Here's an updated version: WindowsTestApp 这是更新的版本: WindowsTestApp
What I've done: 我所做的:
Removed use of the path
variable in wlCommonInit()
. 删除了wlCommonInit()
中的path
变量的使用。
Added the changeHash: false
option to $.mobile.changePage()
. 在$.mobile.changePage()
添加了changeHash: false
选项。
For example: $.mobile.changePage("Pages/MyAccount.html", { changeHash: false });
例如: $.mobile.changePage("Pages/MyAccount.html", { changeHash: false });
In WindowTestApp.html 在WindowTestApp.html中
Removed this line from the HEAD
element: 从HEAD
元素中删除了这一行:
<script>window.$ = window.jQuery = WLJQ;</script>
In js\\jquery-1.10.2.js: 在js \\ jquery-1.10.2.js中:
Find 找
xhr.open(s.type, s.url, s.async); xhr.open(s.type,s.url,s.async);
Change to 改成
s.url = s.url.replace("x-wmapp0:///", ""); s.url = s.url.replace(“ x-wmapp0:///”,“”);
xhr.open(s.type, s.url, s.async); xhr.open(s.type,s.url,s.async);
Step 3 is correct use of changePage
in case of using WL.Client.reloadApp()
. 在使用WL.Client.reloadApp()
情况下,第3步是changePage
正确使用。
Step 4 seems to be a bug in jQuery/jQuery Mobile specific to handling to file location in Windows Phone. 步骤4似乎是jQuery / jQuery Mobile中的错误,特定于Windows Phone中文件位置的处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.