2013-01-16 39 views
0

我想在同一個解決方案中瀏覽內部的jqueryMobile頁面(data-page =「mypage」)和普通的(xxxx.php)頁面。我希望它表現爲它如下:jQueryMobile - 如何結合內部頁面和普通頁面刷卡?

  • 從#LISTA-X進行刷卡向右,去#listas
  • 從#listas執行新的刷卡向右走的index.php

問題是,如果我在#lista-x上執行滑動操作,它將直接進入index.php。我幾乎看不到它正在執行這兩個操作,也就是說,首先它會轉到#listas,然後轉到index.php。 這是我的代碼(這是爲了讓你瞭解它更容易被簡化):

<!-- EXAMPLE.PHP --> 
    <div data-role="page" id="listas"> 
      <a data-role="button" href="#lista-1">lista 1</a> 
      <a data-role="button" href="#lista-2">lista 2</a> 
      <a data-role="button" href="#lista-3">lista 3</a> 
     </div> 
     <div data-role="page" id="lista-1"> 
      //something... 
     </div> 
     <div data-role="page" id="lista-2"> 
      //something... 
     </div> 
     <div data-role="page" id="lista-3"> 
      //something... 
     </div> 


<script type="text/javascript">  
$("[id='listas']").bind('pageshow', function(){ 
    // Gestos táctiles 
      $(function() { 
       $("body").bind('swiperight', function(event) { 
         window.location = "mov-eventos.php"; 
         // $.mobile.changePage("mov-eventos.php"); 
       }); 

      }); 
    }); 


    $("[id^='lista-']").bind('pageshow', function(){ 
    // Gestos táctiles 
     $(function() { 
      $("body").bind('swiperight', function(event) { 
        $.mobile.changePage("#listas", "slide", false, true); 
      }); 
     }); 
    }); 
</script> 

我怎樣才能解決這個問題,爲了表現我已提前

前?:

感謝解釋

回答

0

問題是,儘管您只選擇了一些元素(例如$("[id^='lista-']")),但您將swiperight事件綁定到body元素,因此swiperight會被觸發兩次。你必須將它綁定到選定的元素。

相關問題