summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Davis <thomasalwyndavis@gmail.com>2013-01-28 23:15:15 -0800
committerThomas Davis <thomasalwyndavis@gmail.com>2013-01-28 23:15:15 -0800
commit14506777d5d48e5463cdaf9f0ddd52de281f83e9 (patch)
treea24a3af006259dfc103f2df901d449f7b419eaa8
parentb288670d13fb4c98a859ea53033258b90af5975e (diff)
parente7ef9ce4055f8a4989116ff530da3fd128cb82ee (diff)
downloadbackbonetutorials-14506777d5d48e5463cdaf9f0ddd52de281f83e9.zip
backbonetutorials-14506777d5d48e5463cdaf9f0ddd52de281f83e9.tar.gz
backbonetutorials-14506777d5d48e5463cdaf9f0ddd52de281f83e9.tar.bz2
Merge pull request #73 from craigjennings11/gh-pages
Fixed some minor issues with "What is a Collection" post
-rw-r--r--_posts/2011-01-26-what-is-a-collection.md15
1 files changed, 8 insertions, 7 deletions
diff --git a/_posts/2011-01-26-what-is-a-collection.md b/_posts/2011-01-26-what-is-a-collection.md
index 639cde8..c812ca5 100644
--- a/_posts/2011-01-26-what-is-a-collection.md
+++ b/_posts/2011-01-26-what-is-a-collection.md
@@ -9,9 +9,9 @@ posturl: http://backbonetutorials.com/what-is-a-collection
Backbone collections are simply an ordered set of [models](/what-is-a-model). Such that it can be used in situations such as;
-* Model: Student, Collection: ClassStudents
+* Model: Student, Collection: ClassStudents
* Model: Todo Item, Collection: Todo List
-* Model: Animals, Collection: Zoo
+* Model: Animal, Collection: Zoo
Typically your collection will only use one type of model but models themselves are not limited to a type of collection;
@@ -28,9 +28,10 @@ Here is a generic Model/Collection example.
console.log("Music is the answer");
}
});
-
+
var Album = Backbone.Collection.extend({
model: Song
+ });
{% endhighlight %}
@@ -49,16 +50,16 @@ Now we are going to populate a collection with some useful data.
console.log("Music is the answer");
}
});
-
+
var Album = Backbone.Collection.extend({
model: Song
});
-
+
var song1 = new Song({ name: "How Bizarre", artist: "OMC" });
var song2 = new Song({ name: "Sexual Healing", artist: "Marvin Gaye" });
var song3 = new Song({ name: "Talk It Over In Bed", artist: "OMC" });
-
+
var myAlbum = new Album([ song1, song2, song3]);
console.log( myAlbum.models ); // [song1, song2, song3]
-
+
{% endhighlight %}