Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created December 14, 2009 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lsmith/255870 to your computer and use it in GitHub Desktop.
Save lsmith/255870 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 name = e.target.name;
process[name] = true;
setTimeout(function () {
if (process[name]) {
// do stuff (e is available, but its methods are useless)
}
}, 10);
}
function inputHandler(e) {
var name = e.target.name;
if (/* some condition */) {
process[name] = false;
e.stopImmediatePropagation();
e.preventDefault();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment