jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了滑动回去在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

大佬总结

以上是大佬教程为你收集整理的滑动回去在jQuery Mobile?全部内容,希望文章能够帮你解决滑动回去在jQuery Mobile?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。