Skip to content

Instantly share code, notes, and snippets.

@raddevon
Created May 28, 2013 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raddevon/5666828 to your computer and use it in GitHub Desktop.
Save raddevon/5666828 to your computer and use it in GitHub Desktop.
jQuery function to bind both touch and click events simultaneously From http://jsbin.com/ijizat/25/
function touchClick(sel, fnc) {
$(sel).live('touchstart click', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
fnc(event);
event.handled = true;
} else {
return false;
}
});
}
@raddevon
Copy link
Author

The original version of this function from jsbin had both Touch and Click capitalized in the definition. This caused JSLint to interpret it as a prototype rather than a function and give a warning because I had not used new to instantiate the new object. I changed the case to fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment