API Docs for: 0.9.3
Show:

Lateralus.Component.View Class

Extends Backbone.View

This class builds on the ideas and APIs of Backbone.View.

Methods

addSubview

(
  • Subview
  • [subviewOptions]
)
Lateralus.Component.View

Adds a subview. Subviews are lighter than subcomponents. It is preferable to use a subview rather than a subcomponent when there is clear interdependency between two Views. This pattern is useful when you want to keep display logic well-organized into several Views, but have it compartmentalized within a single component.

Parameters:

Returns:

Lateralus.Component.View:

The instantiated subview.

bindToDOM

() private

Look for any DOM elements within $el that have a class that looks like $this and create a property on this instance with the same name. The attached property is a jQuery object that references the corresponding DOM element.

deferredInitialize

()

A function to be called in the JavaScript thread that follows the one that ran initialize. This can be necessary for situations where setup logic needs to happen after a View has been rendered.

In other words, initialize runs before the View has been rendered to the DOM, and deferredInitialize runs immediately after it has been rendered.

dispose

() chainable

Remove this Lateralus.Component.View from the DOM and cleanly dispose of any references.

getTemplateRenderData

() Object

This method returns the object whose properties are used as render variables in renderTemplate. The method can be overridden.

Returns:

Object:

The raw Backbone.Model data, if this View has a Model. Otherwise, an empty object is returned.

initialize

(
  • [opts]
)

This is called when a Lateralus.Component.View is initialized, it is not called directly.

Lateralus.Component.View subclasses that override initialize must call this base method:

var Base = Lateralus.Component.View;
var baseProto = Base.prototype;

var ExtendedComponentView = Base.extend({
  initialize: function () {
    baseProto.initialize.apply(this, arguments);
    // Other logic...
  }
});

Parameters:

renderTemplate

()

Meant to be called by initialize and infrequently thereafter, this method empties out $el and does a full re-render. render should only be used for partial renders.

toString

() String

Returns:

String:

The name of this View. This is used internally by Lateralus.

Properties

attachDefaultOptions

Object

Meant to be overridden in subclasses. With attachDefaultOptions, you can provide an object of default parameters that should be attached to the View instance when the base initialize method is called. These values can be overridden by the options values that are provided to the View constructor.

className

String | Undefined

The CSS class names specified by this property will be attached to $el when this Lateralus.Component.View is initialized.

Default: undefined

component

Lateralus.Component final

A reference to the Lateralus.Component to which this Lateralus.Component.View belongs.

parentView

Lateralus.Component.View | Null

If this is a subview of another Lateralus.Component.View, this property is a reference to the parent Lateralus.Component.View.

Default: null

subviews

Array(Lateralus.Component.View)

The subviews of this object. Do not modify this property directly, it is managed by Lateralus.

templatePartials

Object(String) | Undefined

An optional map of template partials to be passed to the Mustache.render call for this View.

Lateralus.Component.View.extend({
  templatePartials: {
    myNamePartial: 'Hello my name is {{name}}.'
  }
});

Default: undefined