0.0.11 • Published 8 years ago

vdom-input v0.0.11

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

vdom input

virtual-dom wrapper around an input element. Returns an observable state object usable with the mercury interface.

install

$ npm install vdom-input

example

var vdom = require('virtual-dom');
var h = vdom.h;
var Input = require('vdom-input');

// return observable state object
var state = Input({

  value: 'example',

  // passed to html element
  attrs: {
    style: {
      color: 'red'
    },
    placeholder: 'placeholder'
  },

  // tab in an input that contains text
  onComplete: function() {
    console.log('complete');
  },
  // backspace in an input without any value
  onDelete: function() {
    console.log("delete");
  }

});

var loop = require('main-loop')(state(), Input.render, vdom);
state(loop.update);
document.getElementById('content').appendChild(loop.target);

methods

Input.hasValue(state)

Return boolean