[Pkg-javascript-commits] [backbone] 47/74: Allowing a collection to be passed into a model via the options.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:08 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.3.0
in repository backbone.

commit ece51d2383b3e972ff5ba64eb152f324b7fb6d9e
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Thu Nov 4 23:45:48 2010 -0400

    Allowing a collection to be passed into a model via the options.
---
 backbone.js   | 1 +
 test/model.js | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/backbone.js b/backbone.js
index 7c0ccfd..87d7372 100644
--- a/backbone.js
+++ b/backbone.js
@@ -112,6 +112,7 @@
     this.cid = _.uniqueId('c');
     this.set(attributes || {}, {silent : true});
     this._previousAttributes = _.clone(this.attributes);
+    if (options && options.collection) this.collection = options.collection;
     if (this.initialize) this.initialize(attributes, options);
   };
 
diff --git a/test/model.js b/test/model.js
index 312a6f3..daf1fbb 100644
--- a/test/model.js
+++ b/test/model.js
@@ -34,8 +34,9 @@ $(document).ready(function() {
         this.one = 1;
       }
     });
-    var model = new Model;
+    var model = new Model({}, {collection: collection});
     equals(model.one, 1);
+    equals(model.collection, collection);
   });
 
   test("Model: initialize with attributes and options", function() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list