Lines Matching refs:model

30     col.comparator = function(model) { return model.id; };
66 var comparator = function(model){ return model.id; }; argument
69 model: Model,
91 var model = new MongoModel({_id: 100});
92 var collection = new Backbone.Collection([model], {model: MongoModel});
93 assert.equal(collection.get(100), model);
94 assert.equal(collection.get(model.cid), model);
95 assert.equal(collection.get(model), model);
99 collection2.model = MongoModel;
100 collection2.add(model.attributes);
101 assert.equal(collection2.get(model.clone()), collection2.first());
133 collection.on('change:name', function(model) { assert.ok(this.get(model)); }); argument
159 col.on('add', function(model, collection, options){ argument
160 added = model.get('label');
254 m.on('add', function(model, collection) { argument
256 assert.equal(m, model);
264 col1.on('add', function(model, collection) { argument
265 assert.equal(m, model);
269 col2.on('add', function(model, collection) { argument
270 assert.equal(m, model);
288 var Col = Backbone.Collection.extend({model: Model});
297 return _.map(attrs, function(model) { argument
298 if (model.model) return model.model;
299 return model;
303 collection.add({model: {id: 1, name: 'Alf'}}, {parse: true, merge: true});
330 collection.comparator = function(model) {
331 return this.negative(model.id);
346 col.on('remove', function(model, collection, options) { argument
347 removed = model.get('label');
349 … assert.equal(collection.get(model), undefined, '#3693: model cannot be fetched from collection');
378 collection.model = Even;
462 m.on('remove', function(model, collection) { argument
464 assert.equal(m, model);
472 col1.on('remove', function(model, collection) { argument
473 assert.equal(m, model);
477 col2.on('remove', function(model, collection) { argument
478 assert.equal(m, model);
496 m.sync = function(method, model, options) { options.success(); }; argument
508 m.sync = function(method, model, options) { throw 'should not be called'; };
523 assert.equal(this.syncArgs.model, collection);
536 collection.sync = function(method, model, options) { options.error(); }; argument
550 collection.sync = function(method, model, opts) {
574 var model = collection.create({label: 'f'}, {wait: true});
576 assert.equal(this.syncArgs.model, model);
577 assert.equal(model.get('label'), 'f');
578 assert.equal(model.collection, collection);
589 model: ValidatingModel
602 sync: function(method, model, options) { argument
604 return Backbone.Model.prototype.sync.call(this, method, model, options); argument
609 model: Model,
615 var success = function(model, response, options) { argument
645 model: ValidatingModel
679 assert.notEqual(this.model, FooModel);
684 model: FooModel
686 assert.equal(coll.model, FooModel);
696 var model = new Backbone.Model({a: 1});
698 model,
710 assert.equal(coll.findWhere({a: 1}), model);
716 assert.equal(col.map(function(model){ return model.get('label'); }).join(' '), 'a b c d'); argument
717 assert.equal(col.some(function(model){ return model.id === 100; }), false); argument
718 assert.equal(col.some(function(model){ return model.id === 0; }), true); argument
741 assert.deepEqual(col.groupBy(function(model){ return model.id; })[first.id], [first]); argument
742 assert.deepEqual(col.countBy(function(model){ return model.id; }), {0: 1, 1: 1, 2: 1, 3: 1}); argument
743 assert.deepEqual(col.sortBy(function(model){ return model.id; })[0], col.at(3)); argument
749 var model = new Backbone.Model({a: 4, b: 1, e: 3});
754 model
757 assert.deepEqual(coll.find({a: 4}), model);
759 assert.deepEqual(coll.find('e'), model);
761 assert.deepEqual(coll.filter({a: 4}), [model]);
765 assert.deepEqual(coll.reject({a: 4}), _.without(coll.models, model));
770 assert.deepEqual(coll.partition({a: 4})[0], [model]);
771 assert.deepEqual(coll.partition({a: 4})[1], _.without(coll.models, model));
774 assert.deepEqual(coll.sortBy('a')[3], model);
775 assert.deepEqual(coll.sortBy('e')[0], model);
824 var model = new Backbone.Model({id: 1});
826 collection.reset(model);
827 assert.equal(collection.get(1), model);
837 var collection = new (Backbone.Collection.extend({model: Model}))();
840 collection.each(function(model) { argument
841 assert.equal(model.modelParameter, 'model parameter');
884 collection.model = Model;
907 model: Model
921 collection.model = Backbone.Model.extend({
924 var model = new collection.model({id: 1, valid: true});
925 collection.add([model, {id: 2}], {validate: true});
926 model.trigger('test');
927 assert.ok(collection.get(model.cid));
936 var model = new Backbone.Model();
937 collection.add([model, model]);
954 var collection = new Backbone.Collection([{id: 1}], {model: Model});
955 assert.ok(collection.model === Model);
961 var model = new Backbone.Model({id: 1});
962 var collection = new Backbone.Collection([model]);
963 model.set({id: null});
965 model.set({id: 1});
966 model.set({id: undefined});
973 comparator: function(model){ return model.id; } argument
1049 var model = new Backbone.Model;
1050 model.sync = function(method, m, options){ options.success(); };
1052 collection.create(model, {wait: true});
1061 collection.comparator = function(model){ return model.get('x'); };
1078 var values = _.map(collection.sortBy('x'), function(model) { argument
1079 return model.get('x');
1095 collection.comparator = function(model) { return model.get('x'); };
1097 collection.on('add', function(model) { argument
1098 model.set({x: 3});
1100 added.push(model.id);
1108 var model = {};
1111 model: Backbone.Model.extend({
1113 assert.strictEqual(resp, model);
1118 this.ajaxSettings.success([model]);
1135 var model = { class in AnonymousFunctionf8dce19e8800
1139 model: Backbone.Model.extend({
1149 var collection = new Collection(model, {parse: true});
1157 var model = { class in AnonymousFunctionf8dce19e8b00
1161 model: Backbone.Model.extend({
1172 collection.reset(model, {parse: true});
1181 var model = new Backbone.Model();
1182 var collection = new Backbone.Collection([model]);
1184 assert.deepEqual(options.previousModels, [model]);
1196 collection.on('add', function(model) { argument
1197 assert.strictEqual(model, m3);
1199 collection.on('change', function(model) { argument
1200 assert.strictEqual(model, m2);
1202 collection.on('remove', function(model) { argument
1203 assert.strictEqual(model, m1);
1229 collection.off('remove').on('remove', function(model) { argument
1230 assert.ok(model === m2 || model === m3);
1260 model: Backbone.Model.extend({
1280 var collection = new Backbone.Collection([m], {model: Model});
1299 var Collection = Backbone.Collection.extend({model: Model});
1312 model: Model,
1315 var model = new Model({id: 1});
1316 var collection = new Collection(model);
1318 {model: {id: 1}},
1319 {model: {id: 2}}
1321 assert.equal(collection.first(), model);
1326 collection.model = Backbone.Model.extend({
1374 model: Backbone.Model.extend({idAttribute: '_id'})
1478 model: Model,
1482 assert.ok(collection.model === Model);
1504 collection.once('add', function(model, coll, options) { argument
1516 success: function(model, resp, options) { argument
1548 model: Item
1612 _addReference: function(model) { argument
1615 assert.equal(model, this._byId[model.id]);
1616 assert.equal(model, this._byId[model.cid]);
1617 assert.equal(model._events.all.length, 1);
1620 _removeReference: function(model) { argument
1623 assert.equal(this._byId[model.id], void 0);
1624 assert.equal(this._byId[model.cid], void 0);
1625 assert.equal(model.collection, void 0);
1631 var model = collection.add({id: 1});
1632 collection.remove(model);
1661 var model = new Backbone.Model({id: 1});
1662 model.sync = function(){
1665 collection.create(model, {wait: true});
1670 var StoogeCollection = Backbone.Collection.extend({model: Stooge});
1682 model: function(attrs) {
1698 model: Backbone.Model.extend({
1714 model: function(attrs) {
1734 model: function(attrs) {
1748 model: function(attrs) {
1764 collection.on('add', function(model, coll, options) { argument
1765 assert.equal(model.get('val'), options.index);
1774 collection.on('add', function(model, coll, options) { argument
1880 model: Model
1889 var model = collection.first();
1893 model.trigger('change');
1905 var model = new Backbone.Model({id: 1, title: 'First Post'});
1906 var collection = new Backbone.Collection([model]);
1911 assert.strictEqual(changed.removed[0], model);
1913 collection.remove(model);
1917 var model = new Backbone.Model({id: 1, title: 'First Post'});
1919 var collection = new Backbone.Collection([model, model2]);
1926 assert.ok(_.indexOf(changed.removed, model) > -1 && _.indexOf(changed.removed, model2) > -1);
1928 collection.remove([model, model2]);
1932 var model = new Backbone.Model({id: 1, title: 'First Post'});
1937 assert.strictEqual(addedModels[0], model);
1939 collection.set(model);
1943 var model = new Backbone.Model({id: 1, title: 'First Post'});
1949 assert.strictEqual(addedModels[0], model);
1952 collection.set([model, model2]);
1956 var model = new Backbone.Model({id: 1, title: 'First Post'});
1959 var collection = new Backbone.Collection([model]);
1965 assert.strictEqual(changed.removed[0], model);
1971 var model = new Backbone.Model({id: 1, title: 'First Post'});
1974 var collection = new Backbone.Collection([model, model2]);
1978 assert.strictEqual(removedModels[0], model);
1985 var model = new Backbone.Model({id: 1, title: 'First Post'});
1988 var collection = new Backbone.Collection([model, model2]);
1998 var model = new Backbone.Model({id: 1, title: 'First Post'});
2002 var collection = new Backbone.Collection([model, model2]);
2014 var model = new Backbone.Model({id: 1, title: 'First Post'});
2015 var collection = new Backbone.Collection([model]);
2019 collection.set([model]);