滑动回去在jQuery Mobile?

我正在尝试使用jQuery Mobile,因为我无法在jQTouch中滑动一下页面.但是,对于jQuery Mobile而言,我不知道如何去执行滑动操作,而且如何使刷卡正确返回上一页.我一直在谷歌搜索搜索文档,但找不到,所以我真的很感激一些帮助.

编辑:

我发现这个解决方案,谷歌有点多:

$('body').live('pagecreate',function (event) {
            $('div.ui-page').live("swipeleft",function () {
                var nextpage = $(this).next('div[data-role="page"]');
                // swipe using id of next page if exists
                if (nextpage.length > 0) {
                    $.mobile.changePage(nextpage,'slide');
                }
            });
            $('div.ui-page').live("swiperight",function () {
                var prevpage = $(this).prev('div[data-role="page"]');
                // swipe using id of prevIoUs page if exists
                if (prevpage.length > 0) {
                    $.mobile.changePage(prevpage,'slide',true);
                }
//                history.back();
//                return false;
            });
        });

这确实有效,但似乎并不稳定.当你滑动时,它会来回跳动.我还尝试了最后的注释掉的代码 – history.back(),这是在另一个网站上建议的.但这似乎更加不稳定,导致各种奇怪的跳跃.

解决方法

您可以使用jQuery .live“向左滑动”和“向右滑动”事件.

例:

$(document).ready(function() {

      $('.yourPage').live('swipeleft swiperight',function(event){
          if (event.type == "swiperight") {
              var prev = $("#previndex",$.mobile.activePage);
              var previndex = $(prev).data("index");
              if(previndex != '') {
                  $.mobile.changePage({url:"index.PHP",type:"get",data:"index="+previndex},"slide",true);
              }
          }
          if (event.type == "swipeleft") {
              var next = $("#nextindex",$.mobile.activePage);
              var nextindex = $(next).data("index");
              if(nextindex != '') {
                  $.mobile.changePage({url:"index.PHP",data:"index="+nextindex});
              }
          }
          event.preventDefault();
      });
});

另外,这个YouTube视频也可以帮助您.
http://www.youtube.com/watch?v=Ij1RYI1p7rM

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...