Skip to content

Instantly share code, notes, and snippets.

@zachmayberry
Last active December 13, 2015 18:58
Show Gist options
  • Save zachmayberry/4958813 to your computer and use it in GitHub Desktop.
Save zachmayberry/4958813 to your computer and use it in GitHub Desktop.
A simpler helper for pretty, backbone-like event assignments.
// 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