diff --git a/index.html b/index.html index b8a399ae..303d57c4 100644 --- a/index.html +++ b/index.html @@ -1493,6 +1493,25 @@ bill.set({name : "Bill Jones"}); var Library = Backbone.Collection.extend({ model: Book }); + + +

+ A collection can also contain polymorphic models by overriding this property + with a function that returns a model. +

+ +
+var Library = Backbone.Collection.extend({
+
+  model: function(attrs, options) {
+    if (condition) {
+      return new PublicDocument(attrs, options);
+    } else {
+      return new PrivateDocument(attrs, options);
+    }
+  }
+
+});