Fork me on GitHub
Show:

ViewModel

Extends aeris.Model
Defined in: ../src/viewmodel.js:6

Summary

A representation of a data model, which has been reshaped into a form expected by a view.

Inspired by https://github.com/tommyh/backbone-view-model

Constructor

aeris.util.aeris.ViewModel

Syntax

aeris.util.aeris.ViewModel

(
  • opt_attrs
  • opt_options
)

Summary

Parameters:

Methods

destroy

Syntax

destroy

()

Summary

fetchData

Syntax

fetchData

(
  • opt_options
)
Promise

Summary

Invoke the 'fetch' method on our data model.

Parameters:

  • opt_options Object=

    Options to pass to the aeris.Model#fetch method.

Returns:

getData

Syntax

getData

() Model

Summary

Returns:

Model:

The data model associated with this view model.

getDataAttribute

Syntax

getDataAttribute

(
  • path
)
String

Summary

Returns an attribute of the data model at a given path.

Parameters:

Returns:

syncToModel

Syntax

syncToModel

()

Summary

Uses attribute transforms to sync the view model to the data model.

Properties

attributeTransforms_

Syntax

attributeTransforms_

Object. private

Summary

A hash of transforms to apply to attributes.

Example: { km: function() { return this.getData().get('miles') * 1.609344; } }

this.getData().set('miles', 3.0); this.get('km'); // 4.82803

data_

Syntax

data_

aeris.Model private

Summary

Data model.