2013-01-16 40 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会被触发两次。你必须将它绑定到选定的元素。

相关问题