simple-bind
v1.1.0
Published
Trivially simple one-way data binding for HTML forms
Downloads
8
Readme
simple-bind
Trivially simple one-way binding for HTML forms. Useful for implementing pure functions that depend on a form's current state.
var bind = require("simple-bind");
bind($("#form"), function (state) {
// this function is called whenever the form is changed
// state is an object, mapping field names to current values
});
Example state (uses form-serialize):
{
"select": "2",
"checkbox": [
"checkbox-1",
"checkbox-2"
],
"color": "#000000",
"date": "1992-06-15",
"datetime": "hi",
"datetime-local": "2000-01-01T00:00",
"email": "[email protected]",
"month": "1992-06",
"number": "1234",
"password": "secret",
"radio": "radio-2",
"range": "50",
"search": "my search term",
"tel": "911",
"text": "hi there",
"time": "12:00",
"url": "example.com",
"week": "2015-W01",
"textarea": "hello"
}