Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:33
Show Gist options
  • Select an option

  • Save AndersDJohnson/4200108 to your computer and use it in GitHub Desktop.

Select an option

Save AndersDJohnson/4200108 to your computer and use it in GitHub Desktop.
eat touchend on links
// Wrangling with "ghost clicks" in Sencha Touch... is this hungry enough to eat them?
// Based on http://stackoverflow.com/questions/6457220/sencha-touch-button-handler-called-twice-for-single-click-why
// Put this somewhere global and early. (top of app.js?)
document.addEventListener('touchend', function(e) {
var node = e.target;
while (node) {
if (
(node.localName && node.localName.toLowerCase && node.localName.toLowerCase() === 'a') ||
(node.tagName && node.tagName.toLowerCase && node.tagName.toLowerCase() === 'a')
) {
if (typeof e.preventDefault === 'function') e.preventDefault();
if (typeof e.stopPropagation === 'function') e.stopPropagation();
if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
return false;
}
node = node.parentNode;
}
}, true); // could also try with useCapture of false instead of true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment