Created
April 1, 2014 15:19
-
-
Save mrilikecoding/9916292 to your computer and use it in GitHub Desktop.
data binding for attribute actions
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
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