Home Reference Source
public class | source

Page

Extends:

CoreView → Page

Root view of page

Example:

class DetailPage extends Page {
  title() {
    return 'Detail Page'
  }

  html(data) {
    return `\
    <div>
      <h1>${data.headline}</h1>
    </div>
    `
  }
}

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

Whether having initial data or not

Method Summary

Public Methods
public
public

Return document title

Inherited Summary

From class Core
public

listened(nameOrObj: string | Object, handler: Function)

Add handler or listener for saying message

public

say(name: string, ctx: *)

Cast a message to the listeners

public

Unescape HTML

public

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
public

el: *

Root element

public

parent: *

public

views: {}

Subview children of the view

private

_data: *

public

appendEl(el: Element)

Append child element

public

broadcast(method: string, args: Array)

Cast a message to all children of view

public

For implement after loading completed

public

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(name: string, ctx: object)

Fire event

public

handle(evts: object)

Ssetting listener of events.

public

load(views: object)

For implement creating subviews and setting listener of events.

public

prepareData(defaults: object): object | Item

Prepare data

public

set(name: string, view: View)

Set child view as name after load

public

unload()

For implement unloading subviews

public

update(name: string, newValue: *, oldValue: *): boolean

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

_setEvts(el: Element, hmap: object)

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

_trapEvt(root: View, el: Element, type: string, handler: function)

Bind target event with handler.

private

Public Constructors

public constructor() source

Create a View.

Override:

View#constructor

Public Members

public hasInitData: boolean source

Whether having initial data or not

Public Methods

public destroy() source

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

Override:

View#destroy

public title(): string source

Return document title

Return:

string