1

I'm developing an app that has no use for taphold events, long-presses, and I want to remove them entirely.

The actual problem is the delay that jQuery Mobile UI introduces to allow it to distinguish between tap and taphold events, which causes taps to delay noticeably, making the app feel laggy. Long presses are not needed in many apps, so the delay is often useless.

Note that treating ontouch events as taps just makes it impossible to scroll.

I'm happy to patch the library if necessary, so answers along those lines are welcomed.

How do you remove the delay?

Carl Smith
  • 3,025
  • 24
  • 36
  • see the answers to a similar question here http://stackoverflow.com/questions/5859207/prevent-browser-pop-on-taphold-event, should be possible with `preventDefault()` – Taifun Oct 28 '12 at 18:02
  • I already read that post, but it's not what I'm trying to do and the solutions there didn't work for me. – Carl Smith Oct 28 '12 at 21:45

1 Answers1

3

If removal is all you need that it can be achieved easily. One way would be to remove this functionality all together but it can be done through jQuery Mobile global configuration.

Also I can see this is an old question and jQuery Mobile has moved to version 1.3.1 so my answer is created to work in last version but from my knowledge it will work also on older versions.

All you have to do is change glabal parameter:

$.event.special.tap.tapholdThreshold

It is used to tell (in ms) how much time is needed for tap to be calculated as taphold.

We can rid off taphold if this parameter is set to some huge number.

I made you a working example: http://jsfiddle.net/Gajotres/U4prb/

$(document).bind("mobileinit", function(){
    $.event.special.tap.tapholdThreshold = 10000000000;
});

Also be warned mobileinit MUST be initialized before jQuery Mobile initialization. Just take a look at my example and everything will be clear.

Gajotres
  • 57,309
  • 16
  • 102
  • 130