2014-01-11 37 views
0

我正在使用jQuery Mobile在IBM worklight中開發混合應用程序。IBM Worklight - 多頁應用程序中的導航錯誤

我的應用程序文件夾結構是這樣的:

  • carbikepooling.html(默認文件中jquerymobile創建的應用程序)
  • 網頁文件夾中,包含的文件: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"});});}); 

     } 
    } 

這工作得很好。

現在,我在ownerProfile.html文件,從這個文件中,當我改變頁面createPool.html放在同一個頁面的文件夾爲:

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顯示兩次,我不明白爲什麼。

回答

0

您沒有在問題中指定應用程序結構中的頁面文件夾。

假設它是這樣的:

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

我想這是因爲,一旦你changePage從主HTML文件,該文件是在apps\yourApp\common你現在在apps\yourApp\pages ...

所以,當你想從pages\中的文件移動到pages\中的另一個文件,因爲您已經在pages\中,只需調用HTML文件即可。這意味着,

更改此:

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

要這樣:

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

或者,去一個水平了,背,意思是:../pages/createPool.html

+1

此問題已解決。在問這個問題之前,我已經嘗試了您的解決方案,但沒有任何反應所以,我如何調試這個如下:我寫 - $ .mobile.changePage('../ pages/createPool.html'+ dataurl1,{transition:「slide」});它完美的工作。 – himanshu206

+0

不錯。我已經更新了答案以反映這一點。 –

+0

好的!謝謝..... – himanshu206

相關問題