@@ -9,9 +9,9 @@ posturl: http://backbonetutorials.com/what-is-a-collection
9
9
10
10
Backbone collections are simply an ordered set of [ models] ( /what-is-a-model ) . Such that it can be used in situations such as;
11
11
12
- * Model: Student, Collection: ClassStudents
12
+ * Model: Student, Collection: ClassStudents
13
13
* Model: Todo Item, Collection: Todo List
14
- * Model: Animals , Collection: Zoo
14
+ * Model: Animal , Collection: Zoo
15
15
16
16
Typically your collection will only use one type of model but models themselves are not limited to a type of collection;
17
17
@@ -28,9 +28,10 @@ Here is a generic Model/Collection example.
28
28
console.log("Music is the answer");
29
29
}
30
30
});
31
-
31
+
32
32
var Album = Backbone.Collection.extend({
33
33
model: Song
34
+ });
34
35
35
36
{% endhighlight %}
36
37
@@ -49,16 +50,16 @@ Now we are going to populate a collection with some useful data.
49
50
console.log("Music is the answer");
50
51
}
51
52
});
52
-
53
+
53
54
var Album = Backbone.Collection.extend({
54
55
model: Song
55
56
});
56
-
57
+
57
58
var song1 = new Song({ name: "How Bizarre", artist: "OMC" });
58
59
var song2 = new Song({ name: "Sexual Healing", artist: "Marvin Gaye" });
59
60
var song3 = new Song({ name: "Talk It Over In Bed", artist: "OMC" });
60
-
61
+
61
62
var myAlbum = new Album([ song1, song2, song3]);
62
63
console.log( myAlbum.models ); // [song1, song2, song3]
63
-
64
+
64
65
{% endhighlight %}
0 commit comments