dom-binding-stream
Binds to a DOM node, and emits changes of any inputs/textareas/selects inside it.
This module expects a DOM node with either <textarea>
, <input>
, or <select>
tags as children somewhere inside it (can be as deep in the tree as you want). Those elements should then have the attribute data-binding
which contains a keypath to emit updates under.
Example
Live demo.
Given some HTML that looks like this:
Select box Foo Bar Baz Text Input Radio Button Input
We can set up the binding and listen for changes like so:
var domBinding = ;var map = obj;var merge = ; var output = document; // Listen for changed inputs // Merge all the changes together ; // Log merged changes to console { // Log the changed data to the console console;}