Donal Rafferty
Donal Rafferty

Reputation: 19826

Why does swipe left not work for Jquery mobile?

I have the following code that tries to detect swipes left and right:

    $('#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);
        }); 
    });

However this only detects the right swipe and never detects a left swipe, can anyone explain why?

Upvotes: 2

Views: 6883

Answers (1)

ezanker
ezanker

Reputation: 24738

I created a fiddle and it seems to work fine

DEMO

Maybe for the pageinit, use $(document).on:

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

    });
});

Upvotes: 3

Related Questions