Lines Matching refs:model

109     if (_.isString(iteratee)) return function(model) { return model.get(iteratee); };
114 return function(model) { argument
115 return matcher(model.attributes);
597 var model = this;
600 var serverAttrs = options.parse ? model.parse(resp, options) : resp;
601 if (!model.set(serverAttrs, options)) return false;
602 if (success) success.call(options.context, model, resp, options);
603 model.trigger('sync', model, resp, options);
636 var model = this;
641 model.attributes = attributes;
642 var serverAttrs = options.parse ? model.parse(resp, options) : resp;
644 if (serverAttrs && !model.set(serverAttrs, options)) return false;
645 if (success) success.call(options.context, model, resp, options);
646 model.trigger('sync', model, resp, options);
668 var model = this;
673 model.stopListening();
674 model.trigger('destroy', model, model.collection, options);
679 if (success) success.call(options.context, model, resp, options);
680 if (!model.isNew()) model.trigger('sync', model, resp, options);
765 if (options.model) this.model = options.model;
792 model: Model,
806 return this.map(function(model) { return model.toJSON(options); }); argument
870 var model, i;
872 model = models[i];
876 var existing = this.get(model);
878 if (merge && model !== existing) {
879 var attrs = this._isModel(model) ? model.attributes : model;
893 model = models[i] = this._prepareModel(model, options);
894 if (model) {
895 toAdd.push(model);
896 this._addReference(model, options);
897 modelMap[model.cid] = true;
898 set.push(model);
906 model = this.models[i];
907 if (!modelMap[model.cid]) toRemove.push(model);
935 model = toAdd[i];
936 model.trigger('add', model, this, options);
970 push: function(model, options) { argument
971 return this.add(model, _.extend({at: this.length}, options));
976 var model = this.at(this.length - 1);
977 return this.remove(model, options);
981 unshift: function(model, options) { argument
982 return this.add(model, _.extend({at: 0}, options));
987 var model = this.at(0);
988 return this.remove(model, options);
1074 create: function(model, options) { argument
1077 model = this._prepareModel(model, options);
1078 if (!model) return false;
1079 if (!wait) this.add(model, options);
1086 model.save(null, options);
1087 return model;
1099 model: this.model,
1106 return attrs[this.model.prototype.idAttribute || 'id'];
1126 var model = new this.model(attrs, options);
1127 if (!model.validationError) return model;
1128 this.trigger('invalid', this, model.validationError, options);
1136 var model = this.get(models[i]);
1137 if (!model) continue;
1139 var index = this.indexOf(model);
1145 delete this._byId[model.cid];
1146 var id = this.modelId(model.attributes);
1151 model.trigger('remove', model, this, options);
1154 removed.push(model);
1155 this._removeReference(model, options);
1162 _isModel: function(model) { argument
1163 return model instanceof Model;
1167 _addReference: function(model, options) { argument
1168 this._byId[model.cid] = model;
1169 var id = this.modelId(model.attributes);
1170 if (id != null) this._byId[id] = model;
1171 model.on('all', this._onModelEvent, this);
1175 _removeReference: function(model, options) { argument
1176 delete this._byId[model.cid];
1177 var id = this.modelId(model.attributes);
1179 if (this === model.collection) delete model.collection;
1180 model.off('all', this._onModelEvent, this);
1187 _onModelEvent: function(event, model, collection, options) { argument
1188 if (model) {
1190 if (event === 'destroy') this.remove(model, options);
1192 var prevId = this.modelId(model.previousAttributes());
1193 var id = this.modelId(model.attributes);
1196 if (id != null) this._byId[id] = model;
1406 Backbone.sync = function(method, model, options) { argument
1420 params.url = _.result(model, 'url') || urlError();
1424 …if (options.data == null && model && (method === 'create' || method === 'update' || method === 'pa…
1426 params.data = JSON.stringify(options.attrs || model.toJSON(options));
1432 params.data = params.data ? {model: params.data} : {};
1462 model.trigger('request', model, xhr, options);
1937 var wrapError = function(model, options) { argument
1940 if (error) error.call(options.context, model, resp, options);
1941 model.trigger('error', model, resp, options);