Skip to content

Instantly share code, notes, and snippets.

@ericf
Forked from lsmith/gist:255870
Created December 14, 2009 07:24
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 ericf/255872 to your computer and use it in GitHub Desktop.
Save ericf/255872 to your computer and use it in GitHub Desktop.
document.addEventListener('focus', prepareHandler, true); // capture phase
input.addEventListener('focus', inputHandler, false);
function prepareHandler(e) {
var id = e.target.id;
process[id] = true;
setTimeout(function () {
if (process[id]) {
// do stuff (e is available, but its methods are useless)
}
}, 10);
}
function inputHandler(e) {
var id = e.target.id;
if (/* some condition */) {
process[id] = false;
e.stopImmediatePropagation();
e.preventDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment