iPad understands touchstart / -end and mousestart / -end.
Dismissed as follows:
βββββββββββββββββββββββ¬βββββββββββββββββββββββ¬ββββββββββββββββββββββββββ βFinger enters tablet β Finger leaves tablet β Small delay after leave β βββββββββββββββββββββββΌβββββββββββββββββββββββΌββββββββββββββββββββββββββ€ βtouchstart β touchend β mousedown β β β β mouseup β βββββββββββββββββββββββ΄βββββββββββββββββββββββ΄ββββββββββββββββββββββββββ
You need to determine if the user is on the tablet, and then relay it by touching ...:
/******************************************************************************** * * Dont sniff UA for device. Use feature checks instead: ('touchstart' in document) * The problem with this is that computers, with touch screen, will only trigger * the touch-event, when the screen is clicked. Not when the mouse is clicked. * ********************************************************************************/ var isIOS = ((/iphone|ipad/gi).test(navigator.appVersion)); var myDown = isIOS ? "touchstart" : "mousedown"; var myUp = isIOS ? "touchend" : "mouseup";
and then tie it as follows:
$('#next_item').bind(myDown, function(e) {
You can also make an event that takes care of this, see:
http://benalman.com/news/2010/03/jquery-special-events/
The main normalized event is down:
$.event.special.myDown = { setup: function() { var isIOS = ((/iphone|ipad/gi).test(navigator.appVersion)); var myDown = isIOS ? "touchstart" : "mousedown"; $(this).bind(myDown + ".myDownEvent", function(event) { event.type = "myDown"; $.event.handle.call(this, event); }); }, teardown: function() { $(this).unbind(".myDownEvent"); } };
After jQuery 1.9.0 $.event.handle changes the name to $.event.dispatch , you can write this backup to support both:
// http://stackoverflow.com/questions/15653917/jquery-1-9-1-event-handle-apply-alternative // ($.event.dispatch||$.event.handle).call(this, event); $.event.special.myDown = { setup: function() { var isIOS = ((/iphone|ipad/gi).test(navigator.appVersion)); var myDown = isIOS ? "touchstart" : "mousedown"; $(this).bind(myDown + ".myDownEvent", function(event) { event.type = "myDown"; ($.event.dispatch||$.event.handle).call(this, event); }); }, teardown: function() { $(this).unbind(".myDownEvent"); } };