Input

Input is a basic dom-wrapper for all the input elements, like text fields, selects, textareas, etc. It inherited from the Element class and has partly shared interface.

Events

Unlike other DOM elements, form elements handle a bunch of additional events:

  • disable
  • enable
  • focus
  • blur
  • change

They are handled simultaneously with all the other events. All shortcuts are in place, you can wire and run the events the usual way.

Methods

include, initialize, blur, checked, disable, disabled, enable, focus, form, getValue, select, setValue, value

top ↑include

include(Object methods[, boolean dont_rewrite])

Description

Registers additional methods for the form input element units, like INPUT, SELECT, TEXTAREA.

Example

Input.include({
myMethod: function() {....}
});

$('my_input').myMethod();

top ↑initialize

initialize(raw_dom_element) -> Input
initialize(Object options) -> Input

Description

Basic constructor. It might take a raw dom input element or all the standard Element options, plus an uniformed option of type, which can be one of the standard INPUT tag types or one of the following

  • textarea
  • select
  • multi-select

text - is the default value

Example

new Input(); // -> input#text
new Input({type: 'radio'}) // -> input#radio
new Input({type: 'textarea'}) // -> textarea
new Input({type: 'select'}) // -> selectbox

top ↑blur

blur() -> Element self

Description

Looses the focus on the element.

Example

$('input').blur();

top ↑checked

checked() -> boolean
checked(value) -> Input self

Description

A bidirectional method to work with the checked property

Example

$(input).checked(true);
$(input).checked(); // -> true
$(input).checked(false);
$(input).checked(); // -> false

top ↑disable

disable() -> Element self

Description

Disables the element.

Example

$('element').disable();

top ↑disabled

disabled() -> boolean
disabled(value) -> Input self

Description

A bidirectional method to work with the disabled property

Example

$(input).disabled(true);
$(input).disabled(); // -> true
$(input).disabled(false);
$(input).disabled(); // -> false

top ↑enable

enable() -> Element self

Description

Enables the element.

Example

$('input').enable();

top ↑focus

focus() -> Element self

Description

Puts the focus on the element.

Example

$('input').focus();

top ↑form

form() -> Form

Description

Returns a wrapped form object to which this input field belongs to

Example

$(input).form().submit();

top ↑getValue

getValue() -> mixed value

Description

Unified access to get a form element value.

Example

$('input').getValue();
$('select').getValue();
$('textarea').getValue();
$('multi-select').getValue();

top ↑select

select() -> Element self

Description

Puts the focus on the element and selects its data.

Example

$('input').select();

top ↑setValue

setValue(mixed value) -> Element self

Description

Unified value setter for the form elements.

Example

$('input').setValue('text');
$('select').setValue(1);
$('textarea').setValue('text');
$('multi-select').setValue([1,2,3]);

top ↑value

value() -> mixed the current value
value(value) -> Input self

Description

A bidirectional method to work with Input field values

Example

$(input).value('something');
$(input).value(); // -> 'something'