IBM Worklight-多页应用程序中的导航错误



我正在使用jQuery Mobile在IBM工作灯中开发一个混合应用程序。

我的应用程序文件夹结构如下:

  • carbikepooling.html(在jquerymobile应用程序中创建的默认文件)
  • pages文件夹,包含文件:ownerProfile.html、passengerProfile.html和createPool.html
    另外validateForm.js与carbikepooling.html关联,ownerProfile.js与ownerProfile.html关联,createPool.js与createPool.js

从carbikepooling.html,我将页面更改为放置在页面文件夹中的ownerProfile.html:validationForm.js(与carbikepooling.html关联)

function redirectToProfile(profileId, profileType){
if(profileId == null || profileId == ""){
$("#failMessage").fadeIn();
}
else if(profileType == "Owner"){
var dataurl = '?profileID='+profileId;
$("#failMessage").fadeOut(200, function(){$("#loginSuccess").fadeIn(function(){$.mobile.changePage('pages/ownerProfile.html'+dataurl, {transition: "slide"});});});
}
else{
var dataurl = '?profileID='+profileId;
$("#failMessage").fadeOut(200, function(){$("#loginSuccess").fadeIn(function(){$.mobile.changePage('pages/passengerProfile.html'+dataurl, {transition: "slide"});});});
}
}

这很好用。

现在,当我将page更改为createPool.html文件时,我在ownerProfile.html文件中,该文件位于与相同的pages文件夹中:

ownerProfile.js(与ownerProfile.html文件关联)

$(document).undelegate('#crtPool', 'click').delegate('#crtPool', 'click', function() {
if(update1 == 1 && update2 == 1){
var dataurl1 = '?profileID='+profileId+'&name='+userName;
$.mobile.changePage('pages/createPool.html'+dataurl1, {transition: "slide"});
}
else{
alert("Oops! You have not updated all of your information. To create pool, first update your info (click the settings icon on the right top)");
}
});

问题是,这次没有加载createPool.html文件,因为为定位文件而创建的路径错误为:

GET http://192.168.42.239:10080/CarBikePooling/apps/services/preview/CarBikePooling/common/0/default/pages/pages/createPool.html

正如您所看到的,URL中的pages显示了两次,我不明白为什么。

您没有在问题中指定页面文件夹在应用程序结构中的位置。

假设是这样的:

apps
--- yourApp
------ android
------ iphone
------ common
--------- css
--------- js
--------- my.html
------ pages
--------- my1.html
--------- my2.html
--------- my3.html

我认为这是因为一旦你从主HTML文件changePage,它在appsyourAppcommon,你现在就在appsyourApppages。。。

因此,当您想从pages中的一个文件移动到pages中的另一个文件时,由于您已经在pages中了,只需调用HTML文件即可。含义,

更改此项:

$.mobile.changePage('pages/createPool.html'+dataurl1, {transition: "slide"});

对此:

$.mobile.changePage('createPool.html'+dataurl1, {transition: "slide"});

或者,向上返回一个级别,意思是:../pages/createPool.html

最新更新