tap event not consumed : event raised twice

141 views
Skip to first unread message

Samuel

unread,
Dec 18, 2009, 5:39:24 AM12/18/09
to jQTouch
Hi all jQTouch lovers ;-)

To accelerate my app, I changed all my click event to tap event like
that :
$('a.myClass').bind('tap click', function(e) { ... });

But now, I got some strange bugs, and it's difficult to explain it in
english for me :

I have a button, and clicking on it replace this button by another
one.
But the tap event is also fired for the new button. So, for one "tap"/
click, the callback for the first button and the second callback are
launched.

Is there anything I can do ?

David Kaneda

unread,
Dec 19, 2009, 6:56:56 PM12/19/09
to jqt...@googlegroups.com
It's probably the click that's passing through to the second one (clicks are delayed a bit) — that's why we came up with the custom tap event.

Best,
Dave

Samuel

unread,
Dec 21, 2009, 8:55:00 AM12/21/09
to jQTouch
What is the custom tap event ?
How can I change my code to avoid my problem ?
Thanks,
Sam

David Kaneda

unread,
Dec 21, 2009, 11:18:26 AM12/21/09
to jqt...@googlegroups.com
Sam,

Just use:

$('#mylinks a').tap(myCallback);

instead of $('#mylinks a').click(myCallback) or .bind('click', myCallback)

Best,
Dave

Samuel

unread,
Dec 28, 2009, 12:00:26 PM12/28/09
to jQTouch
Thanks Dave !

You where right, it's the click event that is fired after the tap
event.

To solve that, I used
$('a.myClass').bind(clickTouchEvent, function(e)

With clickTouchEvent a string with tap if I am on the iPhone, or click
if I am on safari on my mac :
clickTouchEvent = isIPhone ? 'tap' : 'click'

Aaron Lord

unread,
Dec 28, 2009, 4:30:13 PM12/28/09
to jqt...@googlegroups.com
This seems like a great idea to me, and it will enable me to develop my app more quickly by testing on Chrome.  But I've seen the performance improvement on the iPhone that comes with using the tap event instead of the click event, and I'm wondering whether the same performance improvement would be seen on a tappable device such as an Android phone...
Reply all
Reply to author
Forward
0 new messages