Input
A generator for an input element that binds the value of the input to an object. This is not an element, but a generator that adds listeners to an input element. If one day, Safari adds support for extending built-in elements, this can be converted.
Example
Input.create('number', {})
// <input ...>
Input.new('number', {})
// Input()Constructor
new Input(options)
options
:
Object
optionaltarget
:
Object
optionalObject to bind to
record
:
Object
optionalDeprecated; use target instead
attribute
:
string
optionalAttribute of the Object to bind to
dump
:
function
optionaltransform textContent to value on change
load
:
function
optionaltransform value for input's content
Instance Methods
Load the target's value into the input.
A nil value clears the input, so an attribute set back to null shows as
empty rather than keeping the last value. The very first load is exempt:
an input built with a value keeps it when the target has nothing yet.
Parameters
e
:
Event
optionalv
:
*
optionalValue to load instead of reading the target.
clear()
Empty the input. Called by Input#_load when the loaded value is
nil; override for inputs where empty isn't an empty value.
Static Methods
Create a bound input and return the DOM element
Parameters
type
:
string
input type (text, number, checkbox, select, date, textarea, button, etc.)
Returns
HTMLElement
the created input element
Create and return an Input instance (access the element via .input)
Parameters
type
:
string
input type (text, number, checkbox, select, date, textarea, button, etc.)
Returns
Input
the Input instance