【问题标题】:Swipe for page transitions?滑动页面转换?
【发布时间】:2013-04-30 04:19:56
【问题描述】:

我正在尝试使用滑动进行页面导航,但我的代码似乎已损坏。这只是我的第二个应用程序,我希望得到一些帮助。我在这里粘贴代码时遇到问题,但我已经上传了我在学校服务器上的内容,所以你可以从那里提取源代码 -

dtc-wsuv.org/jcohen/strings

谢谢!

【问题讨论】:

    标签: jquery ios mobile navigation swipe


    【解决方案1】:

    根据您的源代码,您可以尝试使用on() 而不是live,因为live 在 jQuery 版本 1.7 中已弃用,并且将您的代码包装在 $(document).ready(function() { })$(function() { }) 中以让 jQuery 看到整个 DOM,所以:

    $(document).ready(function() {
        $('.swipe').on("swipeleft", function () {
        var nextpage = $(this).next('div[data-role="page"]');
        if (nextpage.length > 0) {
            $.mobile.changePage(nextpage, "slide", false, true);
        }
    });
    
    $('.swipe').on("swiperight", function () {                                          
        var prevpage = $(this).prev('div[data-role="page"]');
        if (prevpage.length > 0) {
            $.mobile.changePage(prevpage, {
                transition: "slide",
                reverse: true
            }, true, true);
        }
    });
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多