Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swipe event triggers tap event for ipod touch

I am using jquery mobile beta and jquery 1.6. On ipod touch, a swipe event is also trigerring the tap event. This issue is not hapenning on android devices. I am trying to google out the solution, but looks like there are not many with the same problem. Is there something very basic that I am missing??

$("div.totapandswipe").bind('tap',function(event, ui){
    alert('event');
});

$("div.totapandswipe").bind('swipe',function(event, ui){
            alert('event');
});

Thank you for the help!

like image 428
zoom_pat277 Avatar asked Oct 24 '22 07:10

zoom_pat277


2 Answers

I have found that I needed to unbind('click') as the first option in my bind('swipeleft swiperight') function. Since my swipe goes to a new page, that page re-binds the 'click' event for the page that it just left. My utility is a flashcard that tap brings a new card and swiping flips it over. Good luck.

$('#flashVerse').bind('swipeleft swiperight', function(event) {
    console.log(event.type);
    $('#flashVerse').unbind('click');
    if(event.type == 'swipeleft') {
        $.mobile.changePage('flashReference','flip');
    } else {
        $.mobile.changePage('flashReference','flip',true,false);
        console.log('SWIPERIGHT');
    }
});

$('#flashReference').live('pageshow',function(event,ui){
    if((tipsOn() || ls.getItem('tipFlash') == '1') && ui.prevPage.attr('id')!='flashVerse') {
        ls.setItem('tipFlash','0');
        var msg = 'Swipe to flip the card.\n Tap for a new card.\nuse Options to turn Tips back on.';
        if(phoneGap) navigator.notification.alert(msg,dummy,'Flash Cards','OK');
        else alert(msg);
    }
    $('#lnkFlashVerse').addClass('ui-btn-active').addClass('ui-state-persist');
    $('#lnkFlashReference').removeClass('ui-btn-active').removeClass('ui-state-persist');
    $('#flashReference').bind('click', function(event) {
        console.log(event.type);
        newFlashCard();
        //$('#flashReference div[data-role="content"]').append('clicked ');
    });
});
like image 171
Brian Seim at EvoDynamic Inc Avatar answered Oct 27 '22 11:10

Brian Seim at EvoDynamic Inc


This seemed to help me:

$("selector").swiperight(function (e) {
  if (e.type === "swiperight") {
    myHandler(e);
  }
});

It's lame that this would be an issue. Jqm bug on this yet?

like image 33
jaketrent Avatar answered Oct 27 '22 11:10

jaketrent