FormView
A FormView is data fields to bind input, select or textarea by theirs names.
Example:
// Create a FormView bound to loginForm
views.form = new FormView('loginForm');
evts.form_submit = function(sender, e) {
var body = this.data;
http.post('/login', { body });
}
{@lang xml}
<form id="loginForm">
<input type="text" name="email">
<input type="password" name="password">
<button type="submit">Sign in</button>
</form>
Method Summary
Public Methods | ||
public |
findEl(id: *): * also returns form element by name. |
|
public |
formatLocalDateTime(date: *): * |
|
public |
getValueOf(field: string): Any Get field value as the type. |
Private Methods | ||
private |
_assignFromFields(data: {}): * |
|
private |
_setFieldValue(name: *, val: *) |
|
private |
_valueAsType(el: *): * |
Inherited Summary
From class Core | ||
public |
Add handler or listener for saying message |
|
public |
Cast a message to the listeners |
|
public |
unescapeHtml(escaped: String): String Unescape HTML |
|
public |
unlistened(name: string, -: Function) Remove handler or listener |
|
private |
_callR(args: *, target: *, method: *, methodOwner: *) |
|
private |
_isFn(f: *): * |
|
private |
_isStr(v: *): * |
|
private |
_listened(name: *, handler: *) |
|
private |
_privates(): {"_F_obs": *} Return non-enumerable attribute definitions. |
|
private |
_say(targetName: *, name: *, ctx: *) |
From class View | ||
public get |
data: * data to elements text or value, innerHTML of elements |
|
public set |
|
|
public |
contentEl: * |
|
public |
el: * Root element |
|
public |
parent: * |
|
public |
views: {} Subview children of the view |
|
private |
_data: * |
|
public |
appendEl(el: Element) Append child element |
|
public |
Cast a message to all children of view |
|
public |
For implement after loading completed |
|
public |
destroy() Destroy all chidren, unload, and destroy binder, teardown events |
|
public |
findEl(id: *): Element Find an element that has specified data-id else call getElementById |
|
public |
Fire event |
|
public |
Ssetting listener of events. |
|
public |
For implement creating subviews and setting listener of events. |
|
public |
prepareData(defaults: object): object | Item Prepare data |
|
public |
Set child view as name after load |
|
public |
unload() For implement unloading subviews |
|
public |
Called when the binding data is updated. |
|
private |
|
|
private |
|
|
private |
_build(root: *, props: *) _loaded resolve after all done |
|
private |
_buildFromHtml(data: *): * |
|
private |
_firstEl(el: *): * |
|
private |
|
|
private |
_parseEvts(evts: *, emap: *) |
|
private |
_privates(): * |
|
private |
Set data to subviews or elements in the view. |
|
private |
Bind targets with event handler set. |
|
private |
_setFieldValue(name: *, val: *): boolean |
|
private |
_setRootNode(root: *, parent: *, data: *) Set root node element to this.el |
|
private |
_setVal(el: *, val: *) |
|
private |
_setupProps(props: *): * |
|
private |
|
|
private |
Bind target event with handler. |
|
private |
|
Public Members
Public Methods
public findEl(id: *): * source
also returns form element by name.
Override:
View#findElParams:
Name | Type | Attribute | Description |
id | * |
Return:
* |
public getValueOf(field: string): Any source
Get field value as the type.
Params:
Name | Type | Attribute | Description |
field | string | target field |
Return:
Any | the value |
Private Methods
private _assignFromFields(data: {}): * source
Params:
Name | Type | Attribute | Description |
data | {} |
|
Return:
* |
private _setFieldValue(name: *, val: *) source
Override:
View#_setFieldValueParams:
Name | Type | Attribute | Description |
name | * | ||
val | * |