2012-08-07 71 views
0

大家好我有html文件,div中有各種不同的頁面。現在我想從一個頁面導航到另一個頁面,我正在使用$.mobile.changePage("#test"),但導航到test.html不會發生。如果我爲test.html使用不同的html文件並將其命名爲$.mobile.changePage(("test.html"));,則會導航。

我也試過用loadPage,但它也不能解決我的問題。任何建議將不勝感激,提前致謝。

這裏是我的代碼:

<body> 
<div data-role="page" id="firstPage" onclick=callSecondPage() class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="firstPage" id="firstPage"> 
     </div> 

     <script type="text/javascript"> 
      function callSecondPage() 
      { 
       alert ("Inside callPage"); 

       $.mobile.changePage('#secondPage'); 

      } 
     </script> 

</div> 

<div data-role="page" id="secondPage" onclick=callThirdPage() class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="secondPage" id="secondPage"> 
     </div> 

     <script type="text/javascript"> 
      function callThirdPage() 
      { 
       alert ("Inside callPage"); 

       $.mobile.changePage('#thirdPage'); 

      } 
     </script> 

</div> 

<div data-role="page" id="thirdPage" onclick=callFourthPage() class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="thirdPage" id="thirdPage"> 
     </div> 

     <script type="text/javascript"> 
      function callFourthPage() 
      { 
       alert ("Inside callPage"); 

       $.mobile.changePage('#fourthPage'); 

      } 
     </script> 

</div> 

<div data-role="page" id="fourthPage" class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="fourthPage" id="fourthPage"> 
     </div> 

</div> 

<div data-role="page" id="fifthPage" class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="fifthPage" id="fifthPage"> 
     </div> 

</div> 

<div data-role="page" id="sixthPage" class="type-home"> 

     <div data-role="button"> 
      <input type="submit" data-role="button" value="sixthPage" id="sixthPage"> 
     </div> 

</div> 

之前談到上面的html文件瀏覽其他網頁,而現在$.mobile.changePage('#secondPage'); secondPage沒有從第一頁導航。但是,應用程序的,如果相同的代碼我放在index.html的(即切入點,然後適當的導航發生。

+0

你能爲我們提供用於JQM頁面的HTML嗎? – 2012-08-07 09:19:54

回答

0

你應該寫

$.mobile.changePage($("#test")) 

正在等待頁面加載調用$ .mobile.changePage?你需要讓我們在這裏看到一些代碼...

+0

使用這個我得到的錯誤爲:TypeError:表達式的結果toPage.data 「page」)'[undefined]不是一個對象。at file:///android_asset/www/jquery.mobile-1.1.1/jquery.mobile-1.1.1.js:2843 – PPD 2012-08-07 09:32:31

+1

$ .mobile.changePage(「 #TEST「)應該足夠了,所以我不驚訝這沒有什麼區別。如果頁面沒有改變,那麼JQM沒有使用該id找到一個帶有data-role =「page」的div。不幸的是,沒有看到您使用的HTML,我無法再提供任何幫助。 – 2012-08-07 09:43:01