View

Skull. View

new View(options)

Parameters:
Name Type Description
options Object
Source:

Members

__children__ :Object

Automatically (and not, if you wish) creates and renders nested views. Actually is a hash. Each field can take 4 forms:

  • '.js-someSelector': MyViewClass
  • '.js-anotherSelector': [MyViewClass, {answer: 42}] // second element will be passed to MyViewClass constructor
  • '.js-yetAnotherSelector': [MyViewClass, 'someMethodName'] // this['someMethodName'] will be called in proper context (this), and result will be passed to MyViewClass constructor
  • '.js-selectorToo': [MyViewClass, function () { return {answer: 42} }] // second element will be called in proper context, and result will be passed to MyViewClass constructor

All mentioned views will be placed to this.children hash for further managing during Skull.View#onRender.

Type:
  • Object
Source:

__ui__

Automatically (and not, if you wish) creates links to nodes inside your view. This is useful (and handy), when you change some node's attributes several times during view's lifecycle. Actually is a config in following form: somePrettyName: '.some .selector'

All defined bits will be placed to this.ui hash for further managing during Skull.View#onRender.

Source:

_parentResult :function

Type:
  • function
Source:

replaceEl

Whether this.$el will be completely replaced on rendering

Source:

Methods

onBeforeRemove()

Cleans up: removes nested views, shuts down events both DOM and Backbone's

Source:

onRender()

Performs declarative bindings: __children__, __ui__, events. Call this method when html is ready.

Source:

registerChild(viewNameopt, viewClass, options) → {View}

Registers nested view

Parameters:
Name Type Attributes Description
viewName String <optional>

defaults to cid, if falsy

viewClass View
options Object
Source:
Returns:
Type
View

remove()

Acts as destructor

Source:

render() → {*}

Default rendering procedure: renders this.collection or this.model or {}. Feel free to override if needed.

Source:
Returns:

data passed to template

Type
*

rr(tplDataopt, replaceopt)

Shortcut for rendering this.tpl to this.$el (or instead of this element)

Parameters:
Name Type Attributes Default Description
tplData Skull.Model | Skull.Collection | Object <optional>
{}

if this parameter have .toTemplate method, it would be called and result will be passed instead

replace Boolean <optional>
false

whether replace whole $el or only replace it's .html()

Source:

unregisterChild(viewName)

Carefully removes nested view

Parameters:
Name Type Description
viewName String
Source:

Skull. View

new View()

Fused with automagic, Skull.View is highly configurable tool for creating and manipulating your app's views. Core differences with vanilla Backbone.View is following:

  • Full-cycle nested views automated managing, Skull.View#\__children\__
  • Handy access to often used nodes inside view, Skull.View#\__ui\__
  • Preventing memory leaks and "zombie" callbacks with more thorough Skull.View#remove method
Source:

Members

__children__ :Object

Automatically (and not, if you wish) creates and renders nested views. Actually is a hash. Each field can take 4 forms:

  • '.js-someSelector': MyViewClass
  • '.js-anotherSelector': [MyViewClass, {answer: 42}] // second element will be passed to MyViewClass constructor
  • '.js-yetAnotherSelector': [MyViewClass, 'someMethodName'] // this['someMethodName'] will be called in proper context (this), and result will be passed to MyViewClass constructor
  • '.js-selectorToo': [MyViewClass, function () { return {answer: 42} }] // second element will be called in proper context, and result will be passed to MyViewClass constructor

All mentioned views will be placed to this.children hash for further managing during Skull.View#onRender.

Type:
  • Object
Source:

__ui__

Automatically (and not, if you wish) creates links to nodes inside your view. This is useful (and handy), when you change some node's attributes several times during view's lifecycle. Actually is a config in following form: somePrettyName: '.some .selector'

All defined bits will be placed to this.ui hash for further managing during Skull.View#onRender.

Source:

_parentResult :function

Type:
  • function
Source:

replaceEl

Whether this.$el will be completely replaced on rendering

Source:

Methods

onBeforeRemove()

Cleans up: removes nested views, shuts down events both DOM and Backbone's

Source:

onRender()

Performs declarative bindings: __children__, __ui__, events. Call this method when html is ready.

Source:

registerChild(viewNameopt, viewClass, options) → {View}

Registers nested view

Parameters:
Name Type Attributes Description
viewName String <optional>

defaults to cid, if falsy

viewClass View
options Object
Source:
Returns:
Type
View

remove()

Acts as destructor

Source:

render() → {*}

Default rendering procedure: renders this.collection or this.model or {}. Feel free to override if needed.

Source:
Returns:

data passed to template

Type
*

rr(tplDataopt, replaceopt)

Shortcut for rendering this.tpl to this.$el (or instead of this element)

Parameters:
Name Type Attributes Default Description
tplData Skull.Model | Skull.Collection | Object <optional>
{}

if this parameter have .toTemplate method, it would be called and result will be passed instead

replace Boolean <optional>
false

whether replace whole $el or only replace it's .html()

Source:

unregisterChild(viewName)

Carefully removes nested view

Parameters:
Name Type Description
viewName String
Source: