-
Book Overview & Buying
-
Table Of Contents
Learning Yeoman
By :
The Backbone.Collection class is used to store an ordered set of models; you can bind to collection events and fetch data from the server with RESTful routes and also include a full suite of Underscore.js methods.
For more information on Backbone.Collection, visit http://goo.gl/lJvDE1.
To create a new collection, use the backbone:collection subgenerator as follows:
$ yo backbone:collection posts
In the preceding command:
The backbone:collection subgenerator is invoked with the name of the collection set to posts
The subgenerator then creates a new file located in the app/scripts/collections directory
As collections are ordered sets of models, the collection should have the model property set to a model that the collection is of; this collection is going to contain a set of post models.
Open the app/scripts/collections/posts.coffee file and add the following content:
define ['underscore', 'backbone', 'models/post'], (_, Backbone, PostModel) -> ...
Change the font size
Change margin width
Change background colour