Declarative JS click handler
click-handler is a very small library that allows you to bind click events to interactive HTML elements in a declarative way.
Example usage
HTML
Declare handlers by adding a data-handler="handler-name"
attribute. Multiple handlers can be added by separating them with white-space.
My app example other example two handlers
JavaScript
You can register handlers individually:
{ e; console;}clickHandler; // or clickHandler;
…or register an object of handlers in one go:
var handlers = { e; console; } { e; console; }clickHandler; // or clickHandler;
Unregistering a handler can be done as follows:
clickHandler;
…or to unregister multiple handlers:
clickHandler;
Options
click-handler for now has two configurable options:
clickHandler;
Installation
You can install click-handler using npm:
npm install click-handler [--save]
License
click-handler is available under the MIT license