2013-03-16 84 views
1

我在這裏有一段我​​的JQMobi代碼。問題是,它不會動態切換頁面:JQmobi - 動態切換頁面

<div title='Whatever' id="main" class="panel" selected="true" data-tab="navbar_home" data-footer="none"> 
     <div class="swipe_area"> 
      <!-- nothing here, just for swiping to not disturb other elements --> 
      <- Swipe me -> 
     </div> 
     <script> 
      var init_swipe = function() { 
      $(".swipe_area").swipeListener({ 
        vthreshold: 30, 
        hthreshold: 80, 
        callBack: function (dir) { 
         if(dir.left) { 
          window.location.href = "#menulink3"; 
          alert("go to menulink3"); 
         } 
         else if(dir.right) { 
          window.location.href = "#menulink2"; 
          alert("go to menulink2"); 
         } 
        } 
       }); 
      }; 
      window.addEventListener("load", init_swipe, false); 
     </script> 
</div> 
<div title='Whatever' id="menulink2" class="panel" selected="true" data-tab="navbar_home" data-footer="none"> 
    content of menulink2 
</div> 
<div title='Whatever' id="menulink3" class="panel" selected="true" data-tab="navbar_home" data-footer="none"> 
    content of menulink3 
</div> 

的網址並在瀏覽器中改變,它提供了一個警報(只是要確定),但在頁面沒有開關。另外,正常的href鏈接工作得很好。是否有一個jqmobi函數需要刷新或刷新?

在此先感謝

回答

1

你不改變window.location導航。看看$.ui.loadContentDiv以編程方式進行。

+0

嗨Irvin,我確實發現它。你是對的,像雨一樣。但我無法找到一個按鈕來讓你的答案是正確的答案 – Matt 2013-03-21 09:21:22