Created
October 26, 2015 23:41
-
-
Save balanza/432a4165e4ea7d9f9fc8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//this is the handler | |
var onClick = function(e){ | |
alert('button clicked just one time'); | |
}; | |
//this is the "once" function, | |
// that is a function that executes only once, forever | |
var onlyOnce = _.once(onClick); | |
//here the handler is bound to the event | |
document.getElementById("myBtn").addEventListener("click", onlyOnce); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment