Class: Form

Form

new Form(options, data)

Parameters:
Name Type Argument Description
options Object <optional>

Class options.

data * <optional>

Class data

Source:

Extends

Methods

addClass(cssClass)

Adds new class name to element.

Parameters:
Name Type Description
cssClass string

New class name for the element.

Inherited From:
Source:

appendToDocumentBody()

Appends view into document's body.

Inherited From:
Source:

appendView(view)

Appends a new view into this view's element as a child.

Parameters:
Name Type Description
view spark.core.View

A spark.View instance to append.

Inherited From:
Source:

<private> bindEvents_()

This method is responsible from binding DOM events to the element of this view. It uses native DOM event names which is all lowercase. If your options has an event name and a callback function in events object View will bind and listen those events automatically.

Inherited From:
Source:

createButton(options)

Creates button with the options.

Parameters:
Name Type Description
options Object

Options to create a button component.

Source:

<private> createContainers_()

Creates DOM element to hold input and button elements.

Source:

<private> createDomElement_()

Creates the element with the configuration passed to constructor.

Inherited From:
Source:

createInput(options)

Creates field component from passed option using FieldFactory. FIXME: Creating LabeledInput should be handled in FieldFactory.

Parameters:
Name Type Description
options Object

Field options to create a field component.

Source:

destroy()

Destroys the view. It will unlisten all binded events including the DOM events and destroy all child views finally remove the element from document.

Inherited From:
Source:

disable()

Disable view.

Inherited From:
Source:

emit(eventName, data)

Dispatches an event and calls all listeners listening for events of this event. See also goog.events.Listenable.prototype.dispatchEvent

Parameters:
Name Type Argument Description
eventName string

Name of the event.

data * <optional>

Data which will passed to listeners

Inherited From:
Source:

enable()

Enable view.

Inherited From:
Source:

freeze()

Freezes object to prevent adding new properties, updating or deleting existing properties.

Inherited From:
Source:

getAttribute(name)

Native getAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

Inherited From:
Source:

getButtons() → {Array.<spark.components.Button>}

Returns inputs

Source:
Returns:
Type
Array.<spark.components.Button>

getButtonsContainer() → {spark.core.View}

Returns buttons container

Source:
Returns:
Type
spark.core.View

getChildren() → {Array.<spark.core.View>}

Returns the child views.

Inherited From:
Source:
Returns:

DOM element of this view.

Type
Array.<spark.core.View>

getClass() → {string}

Returns class name of the element.

Inherited From:
Source:
Returns:

Class name.

Type
string

getClassList() → {Array}

Returns class list of the element.

Inherited From:
Source:
Returns:

List of class names.

Type
Array

getCssClass(options, optionalClass)

Helper method to set css class to options set.

Parameters:
Name Type Argument Description
options Object

Class options.

optionalClass string <optional>

Optinal CSS class which will added to default.

Inherited From:
Source:

getData()

Returns form data from DOM elements. This method may be useful for serializing the form data.

Source:

getDomId() → {string|null}

Returns the DOM id if exists, otherwise it will return null.

Inherited From:
Source:
Returns:
Type
string | null

getElement() → {Element}

Returns the DOM element.

Inherited From:
Source:
Returns:

DOM element of this view.

Type
Element

getHeight() → {number}

Returns the height of the element.

Inherited From:
Source:
Returns:

View element height.

Type
number

getInputByName(name) → {Array.<spark.components.Field>|null}

Returns a field by name.

Parameters:
Name Type Description
name string

Field name.

Source:
Returns:
Type
Array.<spark.components.Field> | null

getInputs() → {Array.<spark.components.Field>}

Returns inputs

Source:
Returns:
Type
Array.<spark.components.Field>

getInputsContainer() → {spark.core.View}

Returns input container

Source:
Returns:
Type
spark.core.View

getOption() → {*}

Returns value of a key in options object.

Inherited From:
Source:
Returns:

Value of key or null.

Type
*

getOptions() → {Object}

Returns all options object.

Inherited From:
Source:
Returns:

Options object.

Type
Object

getUid() → {string}

Return unique id.

Inherited From:
Source:
Returns:

Unique id of this component.

Type
string

getWidth() → {number}

Returns the width of the element.

Inherited From:
Source:
Returns:

View element width.

Type
number

hasClass(cssClass) → {boolean}

Returns true if element has that class name.

Parameters:
Name Type Description
cssClass string

Name of the class which will be tested.

Inherited From:
Source:
Returns:

Whether element has a class name or not.

Type
boolean

isDestroyed() → {boolean}

Returns the object's destroy state.

Inherited From:
Source:
Returns:

Whether the object is destroyed or not.

Type
boolean

isDisabled()

Returns the current disabled state of the button.

Inherited From:
Source:

off()

Override Object::off to remove events binded to DOM element.

Inherited From:
Source:

on()

Override Object::on to support two way binding for DOM events.

Inherited From:
Source:

once()

Override Object::once to support two way binding for DOM events.

Inherited From:
Source:

removeAttribute(name)

Native removeAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

Inherited From:
Source:

removeClass(cssClass)

Remove a class name from the element.

Parameters:
Name Type Description
cssClass string

Name of the class which will be removed.

Inherited From:
Source:

removeFromDocument() → {boolean}

Removes element from DOM if it is in DOM.

Inherited From:
Source:
Returns:

Whether element removed from document or not.

Type
boolean

render(target)

Renders element into another View instance or a DOM element. Be aware that this method only appends the element of this class into another element. If the parent element is not in DOM, this method will not append the parent into DOM. Also you can use this method with renderTo option. If you pass renderTo as a View instance or DOM element, View will call render method by default.

Parameters:
Name Type Description
target spark.core.View | Element

Target view or element to be rendered.

Inherited From:
Source:

setAttribute(name, value)

Native setAttribute wrapper.

Parameters:
Name Type Description
name string

Atrribute name.

value string

Attribute value.

Inherited From:
Source:

setClass(cssClass)

Sets the class name of element. This will override existing class names. Use @addClass if you want to add new class name to the element.

Parameters:
Name Type Description
cssClass string

Class name.

Inherited From:
Source:

setData()

Sets form data and update fields with the data. Data should be an object and keys should match field names in this form. Values should be string.

Source:

setDomId(domId)

Sets DOM id.

Parameters:
Name Type Description
domId string

Id of the element.

Inherited From:
Source:

setHeight(height)

Sets height of this view's DOM element.

Parameters:
Name Type Description
height string | number

Height of the element. It can be string with 'px' value or just number.

Inherited From:
Source:

setOptions(options)

Sets options object of this class.

Parameters:
Name Type Description
options Object

Options object.

Inherited From:
Source:

setTemplate(template)

Basic templating support for Spark Framework. Currently templates can include variable tags like in Mustache templates. This can be changed in the future versions of the framework.

Variable tags should start with {{ and end with }}. That's borrowed from Mustache. Tags are not whitespace sensitive, so {{name}} and {{ name }} is the same.

Template should also be a function. Just make sure that function returns a string which will be the template. setTemplate will call the template function by passing the data of this View. So you can use class data in your template function. This will allow framework to easily integrate other template engines.

Spark Framework will use Closure Templates as it's default template engine. This is because to maintain the compiled code size advantage. I am also considering to support Mustache and Handlebar templates in Spark.

Parameters:
Name Type Argument Description
template string | function <optional>

HTML string of the element or function which will return the html string. Function will be called with class data. FIXME: Fix annotation for template variable, it should be {string|Function}

Inherited From:
Source:

<private> setUid_()

Sets uid.

Inherited From:
Source:

setWidth(width)

Sets width of this view's DOM element.

Parameters:
Name Type Description
width string | number

Width of the element. It can be string with 'px' value or just number.

Inherited From:
Source:

toggle()

Toggle view state. Disable if enabled, enable if disabled.

Inherited From:
Source:
Spark Framework by Fatih Acet
Copyright © 2014 - Fatih Acet
Documentation generated by JSDoc 3.2.2 on 2015-07-19T22:09:31+00:00 using the DocStrap template.