Skip to content

Instantly share code, notes, and snippets.

@jcf
Forked from jamis/behaviors.js
Created May 20, 2010 12:15
Show Gist options
  • Save jcf/407499 to your computer and use it in GitHub Desktop.
Save jcf/407499 to your computer and use it in GitHub Desktop.
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
var Behaviors = {
add: function(event, behavior, callback) {
return $('*[data-behaviors~=' + behavior + ']').bind(event, callback);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment