Last active
December 13, 2015 18:58
-
-
Save zachmayberry/4958813 to your computer and use it in GitHub Desktop.
A simpler helper for pretty, backbone-like event assignments.
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
// Be sure to include underscore.js in your project | |
app.attachEvents = function( events ) { | |
_.each( events, function(value, key, list) { | |
var ev = key.split(' ')[0], | |
el = key.split(' ')[1], | |
fn = value; | |
jq( el ).bind( ev, fn ); | |
}); | |
}; | |
app.attachEvents({ | |
'click #authenticate': app.signin, | |
'mouseover .tooltip': app.tooltip | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment