Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Created May 5, 2014 11:17
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 nazrdogan/69e8c2185fc48bef94f6 to your computer and use it in GitHub Desktop.
Save nazrdogan/69e8c2185fc48bef94f6 to your computer and use it in GitHub Desktop.
Titanium mobile Event Listener
// bad way
button.addEventListener('click', function (e) {
// something
});
// this is bad as removeEventListener needs to have
// the function originally used in creation passed back
// correct way
var handler = function (e) {
// something
};
button.addEventListener('click', handler);
// now you can clean up
button.removeEventListener('click', handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment