ludo.form.Element


new ludo.form.Element(config)

Super class for form Views.
This class inherits from ludo.View.

Parameters:
Name Type Description
config Object

Configuration when creating the View. These properties and properties from superclass is available

Properties
Name Type Description
name String

Name of element. A call to parentView.getForm().values() will return <name> : <value>.

required Boolean

True to apply validation for required. Default:false

formCss Object

Optional css styling of the form element. Example: { type:'form.Text', formCss:{ "text-align": right }} to right align text of a text input.

validator function

A Validator function to be executed when value is changed. This function should return true when valid, false when invalid. Current value will be passed to this function.

linkWith function

Creates a link with form element with this id. When two form views are linked, they will always have the same value. When one value is changed, the linked form view is automatically updated.

name String

Name of form element

value String | Number

Initial value for form element.
Example: A link between a form.Seekbar and a form.Number.
Example: { type:'form.Text', placeHolder='Enter Valid Value', validator:function(value){ return value == 'Valid Value' } }

Source:
Fires:
  • ludo.form.Element#enable - Fired on enable, argument: ludo.form.event:Element
  • ludo.form.Element#disable - Fired on disable, argument: ludo.form.event:Element
  • ludo.form.Element#key_down - Fired on key down. Arguments: key, value, ludo.form.event:Element
  • ludo.form.Element#key_up - Fired on key up. Arguments: key, value, ludo.form.event:Element
  • ludo.form.Element#key_press - Fired on key up. Arguments: key, value, ludo.form.event:Element
  • ludo.form.Element#focus - Fired on focus received. Arguments: value, ludo.form.event:Element
  • ludo.form.Element#blur - Fired on blur. Arguments: value, ludo.form.event:Element
  • ludo.form.Element#change - Fired on changed value by GUI. Arguments: value, ludo.form.event:Element
  • ludo.form.Element#valueChange - Fired on changed value by GUI or the val function. Arguments: value, ludo.form.event:Element
  • ludo.form.Element#dirty - Fired on new value which is different from initial. Arguments. value, ludo.form.event:Element
  • ludo.form.Element#clean - Fired on new value which is the same as initial. Arguments. value, ludo.form.event:Element
  • ludo.form.Element#value - Fired when a new valid value is set. Arguments. value, ludo.form.event:Element
  • ludo.form.Element#invalid - Fired when a new value is set which is invalid. Arguments. value, ludo.form.event:Element

Methods


clear()

Reset value back to the original value sent(constructor value)

Source:

commit()

Update initial value to current value. These actions will always trigger a commit

  • Form or Model submission
  • Fetching new record for a ludo.model.Model
Source:

disable()

Disable form element

Source:
Returns:

void


enable()

Enable form element

Source:
Returns:

void


getFormEl()

Get reference to input element

Source:
Returns:

DOMElement


isDirty() → {Boolean}

Returns true if current value is different from original value

Source:
Returns:

isDirty

Type
Boolean

isValid() → {Boolean}

Returns true when value of form element is valid, i.e. larger than minValue, matching regex etc.

Source:
Returns:

valid

Type
Boolean

reset()

Reset / Roll back to last committed value. It could be the value stored by last commit method call
or if the original value/default value of this field.

Source:
Returns:

void


rollback()

Alias to reset

Source:

setEnabled(enabled)

Enable or disable form element

Parameters:
Name Type Description
enabled Boolean
Source:

val(val) → {*}

Set or get value. If val argument is set, you will set a value, if not current value
will be returned.

Parameters:
Name Type Description
val String | Number | Array | Object | Boolean
Source:
Returns:
Type
*