Created
May 5, 2014 11:17
-
-
Save nazrdogan/69e8c2185fc48bef94f6 to your computer and use it in GitHub Desktop.
Titanium mobile Event Listener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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