【问题标题】:Why does swipe left not work for Jquery mobile?为什么向左滑动不适用于 Jquery mobile?
【发布时间】:2014-02-13 00:21:19
【问题描述】:

我有以下代码尝试检测左右滑动:

    $('#my_view').bind('pageinit', function() {
        $( '#my_view' ).on( "swipeleft swiperight", "#myItem", function( event ) {
            var listitem = $( this ),
            dir = event.type === "swipeleft" ? "left" : "right";
            console.log("Detected swipe!!!! " + dir);
        }); 
    });

但是,这只会检测到向右滑动而从未检测到向左滑动,谁能解释为什么?

【问题讨论】:

    标签: javascript jquery jquery-mobile swipe


    【解决方案1】:

    我创建了一个小提琴,它似乎工作正常

    DEMO

    也许对于 pageinit,使用 $(document).on:

    $(document).on("pageinit", "#my_view", function(){   
        $('#my_view').on( "swipeleft swiperight", "#myItem li", function( event ){
            alert(event.type);
    
        });
    });
    

    【讨论】:

    • 谢谢,我已经尝试过了,但恐怕也不起作用,JQuery mobile 的这种行为是否存在一些问题?
    • 我不知道。小提琴不适合你吗?
    • Fiddle 是,但它在我的应用程序中根本不起作用,只检测到向右滑动
    猜你喜欢
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 2013-05-11
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多