Skip to content
Anthony Short edited this page Jun 25, 2014 · 2 revisions

When creating views you can pass in any values as attributes:

var view = new View({
  color: 'red'
});

and then get and set those values:

view.set('color', 'blue');

You can also define attributes on your view to enable getters and setters

View.attr('color');
var view = new View({ color: 'red' });

Which lets us do this instead of using .set:

view.color = 'blue';

You can add properties to the attributes too:

View.attr('color', { required: true });

These properties are accessible by plugins. required, default and type are built in.

View.attr('color', { 
  required: true, 
  type: 'string', 
  default: 'red' 
});

The type field uses component/type.