Skip to content

Instantly share code, notes, and snippets.

@mrilikecoding
Created April 1, 2014 15:19
Show Gist options
  • Save mrilikecoding/9916292 to your computer and use it in GitHub Desktop.
Save mrilikecoding/9916292 to your computer and use it in GitHub Desktop.
data binding for attribute actions
var actions = {
action1: function() {},
action2: function() {}
//....
};
$('body').on('click', '[data-action]', function() {
var action = $(this).data('action');
if (action in actions) {
actions[action].apply(this, arguments);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment