Constructor Summary
Public Constructor | ||
public |
constructor(props: object) Create a View. |
Member Summary
Public Members | ||
public |
contentEl: * |
|
public get |
data: * data to elements text or value, innerHTML of elements |
|
public set |
|
|
public |
el: * Root element |
|
public |
parent: * |
|
public |
views: {} Subview children of the view |
Private Members | ||
private |
_data: * |
Method Summary
Public Methods | ||
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 Methods | ||
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 |
|
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: *) |
Public Constructors
public constructor(props: object) source
Create a View.
Override:
Core#constructorParams:
Name | Type | Attribute | Description |
props | object |
|
Properties |
props.rootEl | string | Element |
|
root element ID or root node |
props.parent | Class<View> |
|
parent view this belongs to |
props.contentEl | string | Element |
|
parent element of child views (specified by data-id or id value). |
Public Members
public contentEl: * source
public get data: * source
data to elements text or value, innerHTML of elements
Properties:
Name | Type | Attribute | Description |
data | object |
Example:
view.data = { name: 'Mike', inputAge: { value: 24 }, message: { html: "<p>Hello!</p>" } };
public set data source
public parent: * source
Private Members
private _data: * source
Public Methods
public appendEl(el: Element) source
Append child element
Params:
Name | Type | Attribute | Description |
el | Element | child element |
public findEl(id: *): Element source
Find an element that has specified data-id else call getElementById
Params:
Name | Type | Attribute | Description |
id | * | data-id value |
Return:
Element |
Example:
view.findEl('elementDataId');
public fire(name: string, ctx: object) source
Fire event
Example:
view.fire('move', { newPosition: 1 });
public handle(evts: object) source
Ssetting listener of events.
Params:
Name | Type | Attribute | Description |
evts | object | added listener target (ex. evts.subview_event) |
public load(views: object) source
For implement creating subviews and setting listener of events.
Params:
Name | Type | Attribute | Description |
views | object | added subview target (ex. views.list = new ListView(..)) |
public prepareData(defaults: object): object | Item source
Prepare data
Params:
Name | Type | Attribute | Description |
defaults | object | default data. |
public set(name: string, view: View) source
Set child view as name after load
Example:
parent.set('name', view);
public update(name: string, newValue: *, oldValue: *): boolean source
Called when the binding data is updated.
Params:
Name | Type | Attribute | Description |
name | string | field name |
|
newValue | * | new data value |
|
oldValue | * | old data value |
Private Methods
private _assemble() source
private _bindData() source
private _build(root: *, props: *) source
_loaded resolve after all done
Params:
Name | Type | Attribute | Description |
root | * | ||
props | * |
private _loadViewsEvts() source
private _parseEvts(evts: *, emap: *) source
Params:
Name | Type | Attribute | Description |
evts | * | ||
emap | * |
private _privates(): * source
Return non-enumerable attribute definitions.
Override:
Core#_privatesReturn:
* |
private _setEvts(el: Element, hmap: object) source
Bind targets with event handler set.
Params:
Name | Type | Attribute | Description |
el | Element | event raiser. |
|
hmap | object | handler map. Object<type, value> |
private _setFieldValue(name: *, val: *): boolean source
Params:
Name | Type | Attribute | Description |
name | * | ||
val | * |
private _setRootNode(root: *, parent: *, data: *) source
Set root node element to this.el
Params:
Name | Type | Attribute | Description |
root | * | ||
parent | * | ||
data | * |
private _setVal(el: *, val: *) source
Params:
Name | Type | Attribute | Description |
el | * | ||
val | * |
private _teardownEvts() source
private _trapEvt(root: View, el: Element, type: string, handler: function) source
Bind target event with handler.