Class: View

View(propsopt)

View

Constructor

new View(propsopt)

Create a View.
Parameters:
Name Type Attributes Description
props object <optional>
Properties
Properties
Name Type Attributes Description
rootEl string | Element <optional>
root element ID or root node
parent Class.<View> <optional>
parent view this belongs to
contentEl string | Element <optional>
parent element of child views (specified by data-id or id value).
Source:

Members

data

data to elements text or value, innerHTML of elements
Properties:
Name Type Description
data object
Source:
Example
view.data = { name: 'Mike', inputAge: { value: 24 }, message: { html: "<p>Hello!</p>" } };

data

data to elements text or value, innerHTML of elements
Properties:
Name Type Description
data object
Source:
Example
view.data = { name: 'Mike', inputAge: { value: 24 }, message: { html: "<p>Hello!</p>" } };

el :Node

Root element
Type:
  • Node
Source:

el :Node

Root element
Type:
  • Node
Source:

views :object

Subview children of the view
Type:
  • object
Source:

views :object

Subview children of the view
Type:
  • object
Source:

Methods

_build()

_loaded resolve after all done
Source:

_build()

_loaded resolve after all done
Source:

_privates()

Source:

_privates()

Source:

_setDataToUI()

Set data to subviews or elements in the view.
Source:

_setDataToUI()

Set data to subviews or elements in the view.
Source:

_setEvts(el, hmap)

Bind targets with event handler set.
Parameters:
Name Type Description
el Element event raiser.
hmap object handler map. Object
Source:

_setEvts(el, hmap)

Bind targets with event handler set.
Parameters:
Name Type Description
el Element event raiser.
hmap object handler map. Object
Source:

_setRootNode()

Set root node element to this.el
Source:

_setRootNode()

Set root node element to this.el
Source:

_trapEvt(root, el, type, handler)

Bind target event with handler.
Parameters:
Name Type Description
root View caller
el Element event raiser
type string event type
handler function callback function
Source:

_trapEvt(root, el, type, handler)

Bind target event with handler.
Parameters:
Name Type Description
root View caller
el Element event raiser
type string event type
handler function callback function
Source:

appendEl(el)

Append child element
Parameters:
Name Type Description
el Element child element
Source:

appendEl(el)

Append child element
Parameters:
Name Type Description
el Element child element
Source:

broadcast(method, args)

Cast a message to all children of view
Parameters:
Name Type Description
method string method name
args Array arguments
Source:

broadcast(method, args)

Cast a message to all children of view
Parameters:
Name Type Description
method string method name
args Array arguments
Source:

completed()

For implement after loading completed
Source:

completed()

For implement after loading completed
Source:

destroy()

Destroy all chidren, unload, and destroy binder, teardown events
Source:

destroy()

Destroy all chidren, unload, and destroy binder, teardown events
Source:

findEl(id) → {Element}

Find an element that has specified data-id else call getElementById
Parameters:
Name Type Description
id data-id value
Source:
Returns:
Type
Element
Example
view.findEl('elementDataId');

findEl(id) → {Element}

Find an element that has specified data-id else call getElementById
Parameters:
Name Type Description
id data-id value
Source:
Returns:
Type
Element
Example
view.findEl('elementDataId');

fire(name, ctx)

Fire event
Parameters:
Name Type Description
name string event name
ctx object event context
Source:
Example
view.fire('move', { newPosition: 1 });

fire(name, ctx)

Fire event
Parameters:
Name Type Description
name string event name
ctx object event context
Source:
Example
view.fire('move', { newPosition: 1 });

handle(evts)

Ssetting listener of events.
Parameters:
Name Type Description
evts object added listener target (ex. evts.subview_event)
Source:

handle(evts)

Ssetting listener of events.
Parameters:
Name Type Description
evts object added listener target (ex. evts.subview_event)
Source:

load(views)

For implement creating subviews and setting listener of events.
Parameters:
Name Type Description
views object added subview target (ex. views.list = new ListView(..))
Source:

load(views)

For implement creating subviews and setting listener of events.
Parameters:
Name Type Description
views object added subview target (ex. views.list = new ListView(..))
Source:

prepareData(defaults) → {object|Item}

Prepare data
Parameters:
Name Type Description
defaults object default data.
Source:
Returns:
modified data or item.
Type
object | Item

prepareData(defaults) → {object|Item}

Prepare data
Parameters:
Name Type Description
defaults object default data.
Source:
Returns:
modified data or item.
Type
object | Item

set(name, view)

Set child view as name after load
Parameters:
Name Type Description
name string view name
view View child view. remove if null
Source:
Example
parent.set('name', view);

set(name, view)

Set child view as name after load
Parameters:
Name Type Description
name string view name
view View child view. remove if null
Source:
Example
parent.set('name', view);

unload()

For implement unloading subviews
Source:

unload()

For implement unloading subviews
Source:

update(name, newValue, oldValue) → {boolean}

Called when the binding data is updated.
Parameters:
Name Type Description
name string field name
newValue * new data value
oldValue * old data value
Source:
Returns:
true if setting field value succeeded
Type
boolean

update(name, newValue, oldValue) → {boolean}

Called when the binding data is updated.
Parameters:
Name Type Description
name string field name
newValue * new data value
oldValue * old data value
Source:
Returns:
true if setting field value succeeded
Type
boolean

View(propsopt)

View

Constructor

new View(propsopt)

Create a View.
Parameters:
Name Type Attributes Description
props object <optional>
Properties
Properties
Name Type Attributes Description
rootEl string | Element <optional>
root element ID or root node
parent Class.<View> <optional>
parent view this belongs to
contentEl string | Element <optional>
parent element of child views (specified by data-id or id value).
Source:

Members

data

data to elements text or value, innerHTML of elements
Properties:
Name Type Description
data object
Source:
Example
view.data = { name: 'Mike', inputAge: { value: 24 }, message: { html: "<p>Hello!</p>" } };

data

data to elements text or value, innerHTML of elements
Properties:
Name Type Description
data object
Source:
Example
view.data = { name: 'Mike', inputAge: { value: 24 }, message: { html: "<p>Hello!</p>" } };

el :Node

Root element
Type:
  • Node
Source:

el :Node

Root element
Type:
  • Node
Source:

views :object

Subview children of the view
Type:
  • object
Source:

views :object

Subview children of the view
Type:
  • object
Source:

Methods

_build()

_loaded resolve after all done
Source:

_build()

_loaded resolve after all done
Source:

_privates()

Source:

_privates()

Source:

_setDataToUI()

Set data to subviews or elements in the view.
Source:

_setDataToUI()

Set data to subviews or elements in the view.
Source:

_setEvts(el, hmap)

Bind targets with event handler set.
Parameters:
Name Type Description
el Element event raiser.
hmap object handler map. Object
Source:

_setEvts(el, hmap)

Bind targets with event handler set.
Parameters:
Name Type Description
el Element event raiser.
hmap object handler map. Object
Source:

_setRootNode()

Set root node element to this.el
Source:

_setRootNode()

Set root node element to this.el
Source:

_trapEvt(root, el, type, handler)

Bind target event with handler.
Parameters:
Name Type Description
root View caller
el Element event raiser
type string event type
handler function callback function
Source:

_trapEvt(root, el, type, handler)

Bind target event with handler.
Parameters:
Name Type Description
root View caller
el Element event raiser
type string event type
handler function callback function
Source:

appendEl(el)

Append child element
Parameters:
Name Type Description
el Element child element
Source:

appendEl(el)

Append child element
Parameters:
Name Type Description
el Element child element
Source:

broadcast(method, args)

Cast a message to all children of view
Parameters:
Name Type Description
method string method name
args Array arguments
Source:

broadcast(method, args)

Cast a message to all children of view
Parameters:
Name Type Description
method string method name
args Array arguments
Source:

completed()

For implement after loading completed
Source:

completed()

For implement after loading completed
Source:

destroy()

Destroy all chidren, unload, and destroy binder, teardown events
Source:

destroy()

Destroy all chidren, unload, and destroy binder, teardown events
Source:

findEl(id) → {Element}

Find an element that has specified data-id else call getElementById
Parameters:
Name Type Description
id data-id value
Source:
Returns:
Type
Element
Example
view.findEl('elementDataId');

findEl(id) → {Element}

Find an element that has specified data-id else call getElementById
Parameters:
Name Type Description
id data-id value
Source:
Returns:
Type
Element
Example
view.findEl('elementDataId');

fire(name, ctx)

Fire event
Parameters:
Name Type Description
name string event name
ctx object event context
Source:
Example
view.fire('move', { newPosition: 1 });

fire(name, ctx)

Fire event
Parameters:
Name Type Description
name string event name
ctx object event context
Source:
Example
view.fire('move', { newPosition: 1 });

handle(evts)

Ssetting listener of events.
Parameters:
Name Type Description
evts object added listener target (ex. evts.subview_event)
Source:

handle(evts)

Ssetting listener of events.
Parameters:
Name Type Description
evts object added listener target (ex. evts.subview_event)
Source:

load(views)

For implement creating subviews and setting listener of events.
Parameters:
Name Type Description
views object added subview target (ex. views.list = new ListView(..))
Source:

load(views)

For implement creating subviews and setting listener of events.
Parameters:
Name Type Description
views object added subview target (ex. views.list = new ListView(..))
Source:

prepareData(defaults) → {object|Item}

Prepare data
Parameters:
Name Type Description
defaults object default data.
Source:
Returns:
modified data or item.
Type
object | Item

prepareData(defaults) → {object|Item}

Prepare data
Parameters:
Name Type Description
defaults object default data.
Source:
Returns:
modified data or item.
Type
object | Item

set(name, view)

Set child view as name after load
Parameters:
Name Type Description
name string view name
view View child view. remove if null
Source:
Example
parent.set('name', view);

set(name, view)

Set child view as name after load
Parameters:
Name Type Description
name string view name
view View child view. remove if null
Source:
Example
parent.set('name', view);

unload()

For implement unloading subviews
Source:

unload()

For implement unloading subviews
Source:

update(name, newValue, oldValue) → {boolean}

Called when the binding data is updated.
Parameters:
Name Type Description
name string field name
newValue * new data value
oldValue * old data value
Source:
Returns:
true if setting field value succeeded
Type
boolean

update(name, newValue, oldValue) → {boolean}

Called when the binding data is updated.
Parameters:
Name Type Description
name string field name
newValue * new data value
oldValue * old data value
Source:
Returns:
true if setting field value succeeded
Type
boolean