attr-binder

0.3.1 • Public • Published

binder

A micro-library for binding functions to attributes in the dom. No dependencies. IE8+.

$ npm install attr-binder
var bind = require('binder')

bind(attribute, fn), bind(attribute, starting_node, fn)

Bind a DOM attribute to a function, passing in the attribute's value. The function is passed the node, the attribute value, and the attribute name.

For example, we have a "Post Comment" button that shows a sign-in modal or a comment modal depending on whether the user is signed in.

<p markdown>**This will get turned into markdown using marked.js**</p>
// Automatically render markdown
bind('markdown', function(node) {
    node.innerHTML = marked(node.innerHTML)
})

Readme

Keywords

Package Sidebar

Install

npm i attr-binder

Weekly Downloads

12

Version

0.3.1

License

MIT

Last publish

Collaborators

  • jayrbolton
  • the_swerve