tap fires twice with live("tap")
On mobile safari with live("tap"), tap event fires twice.
And this causes kinds of bugs such as opening dialog twice, sending ajax request twice, etc...
The most notable one is, when you tap a text field, safari sometimes focuses nowhere.
The following is a minimum code that reproduces it.
After loading this page, tap just above/below the text field (not inside it). Normally this focuses on the textfield
- <!DOCTYPE html>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<input name="a" type="text" /><br />
because safari mobile has some margin around textfield for usability.
But in this case after keyboard slides up, focus is not on the text field and tapping keyboard prints no text on it,
even Done button doesn't work.
At this point, focus is actually on BODY tag. You can see it by alert(document.activeElement).
My guess is that this is caused by the doubly fired tap events.
On the first tap event, focus is on the textfield and safari start preparing keyboard slides up.
But on the second tap event, focus is moved to body tag (i don't know why but should be related to the margin around textfield) and when the keyboard is ready it works oddly.
The reason why tap fires twice is,
in the definition of $.event.special.tap, event handler is bound to both mouseXXX and touchYYY like
and each handler fires tap event.
.one( "mouseup touchend", function( event )
I think this should be the following.
Is there any reason why it isn't?
.one( touchStopEvent, function( event )