How do we cope with views that represent collections/lists of models?
The banana module for example can hold 3 stories. Each one of these stories is represented by an article model.
FruitMachine is designed to stay away from your data as much as possible. The only thing it needs to know about is the model associated with each view in order to extract the data for templating.
var Banana = fm.define({
module: 'banana',
initialize: function(options) {
var collection = options.collection;
collection.forEach(this.addItem);
collection.on('add', this.render);
},
addItem: function(item) {
this.add(new Plum({ model: item }));
}
});
var collection = getCollection();
var banana = new Banana({ collection: collection });
The collection could alternatively be defined in layout JSON:
This example (4600e241c7f41c77024c3be3955a8d98b4e14cbc) demonstrates how developers can incorporate collections into their views abstracted away from FruitMachine.
How do we cope with views that represent collections/lists of models?
The banana module for example can hold 3 stories. Each one of these stories is represented by an article model.
FruitMachine is designed to stay away from your data as much as possible. The only thing it needs to know about is the model associated with each view in order to extract the data for templating.
The collection could alternatively be defined in layout JSON: