问题描述
我正在使用IBM Worklight Studio version_6.0.0.20130926-2018。
I am using IBM Worklight Studio version_6.0.0.20130926-2018.
在我的应用程序中,我使用的是jQuery Mobile框架。
我的问题是,当我尝试使用 $ .mobile.changePage
加载 data-role =page
时,页面本身不会刷新。刷新此页面时,JavaScript代码无效。
In my app I am using the jQuery Mobile framework.
My problem is that when I try to load a data-role="page"
using $.mobile.changePage
, the page is not refreshed by itself. When I refresh this page, the JavaScript code is not working.
相反,我收到以下错误:
Instead, I get the following errors:
ReferenceError: WLJQ is not defined profile.html:11
TypeError: $ is undefined jquery.mobile-1.3.2.js:28
ReferenceError: $ is not defined profile.js:3
ReferenceError: WL is not defined
$ .mobile.changePage
代码:
//redirect to profile
function redirectToProfile(profileId){
if(profileId == null || profileId == ""){
$("#failMessage").fadeIn();
}
else{
var dataurl = '?profileID='+profileId;
$("#failMessage").fadeOut(200, function(){$("#loginSuccess").fadeIn(function(){$.mobile.changePage('pages/profile.html'+dataurl, {reloadPage : true,transition: "slide"});});});
}
}
});
如何在Worklight中解决这个问题?
How to solve this in Worklight?
推荐答案
如果我理解正确,您创建了另一个导航到的HTML页面。使用Worklight时,这不是正确的导航方式。 Worklight是一个单页应用程序!,因此您需要使用div元素切换内容而不是在页面之间导航。
有关这方面的更多信息,请访问:
If I understand correctly you created another HTML page that you navigated to. It is not the right way to do navigation when using Worklight. Worklight is a single-page application!, so you need to use a div element that switches the content instead of navigating between pages.More information regarding this can be found here:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/03_02_Building_a_multi_page_application.pdf
这篇关于IBM Worklight 6.0.0.1 - JavaScript不在jQuery Mobile多页面应用程序中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!