Lines Matching full:models
72 // `attributes` object or collection's `models` array behind the scenes.
387 // Backbone **Models** are the basic data object in the framework --
422 // The prefix is used to create the client id which is used to identify models locally.
752 // If models tend to represent a single row of data, a Backbone Collection is
757 // indexes of their models, both in order, and for lookup by `id`.
761 // its models in sort order, as they're added and removed.
762 var Collection = Backbone.Collection = function(models, options) { argument
769 if (models) this.reset(models, _.extend({silent: true}, options));
804 // models' attributes.
814 // Add a model, or list of models to the set. `models` may be Backbone
815 // Models or raw JavaScript objects to be converted to Models, or any
817 add: function(models, options) { argument
818 return this.set(models, _.extend({merge: false}, options, addOptions));
821 // Remove a model, or a list of models from the set.
822 remove: function(models, options) { argument
824 var singular = !_.isArray(models);
825 models = singular ? [models] : models.slice();
826 var removed = this._removeModels(models, options);
834 // Update a collection by `set`-ing a new list of models, adding new ones,
835 // removing models that are no longer present, and merging models that
838 set: function(models, options) { argument
839 if (models == null) return;
842 if (options.parse && !this._isModel(models)) {
843 models = this.parse(models, options) || [];
846 var singular = !_.isArray(models);
847 models = singular ? [models] : models.slice();
868 // Turn bare objects into model references, and prevent invalid models
871 for (i = 0; i < models.length; i++) {
872 model = models[i];
889 models[i] = existing;
893 model = models[i] = this._prepareModel(model, options);
903 // Remove stale models.
906 model = this.models[i];
912 // See if sorting is needed, update `length` and splice in new models.
916 orderChanged = this.length !== set.length || _.some(this.models, function(m, index) {
919 this.models.length = 0;
920 splice(this.models, set, 0);
921 this.length = this.models.length;
924 splice(this.models, toAdd, at == null ? this.length : at);
925 this.length = this.models.length;
949 // Return the added (or merged) model (or models).
950 return singular ? models[0] : models;
954 // you can reset the entire set with a new list of models, without firing
957 reset: function(models, options) { argument
959 for (var i = 0; i < this.models.length; i++) {
960 this._removeReference(this.models[i], options);
962 options.previousModels = this.models;
964 models = this.add(models, _.extend({silent: true}, options));
966 return models;
991 // Slice out a sub-array of models from the collection.
993 return slice.apply(this.models, arguments);
1013 return this.models[index];
1016 // Return models with matching attributes. Useful for simple cases of
1041 this.models = this.sortBy(comparator);
1043 this.models.sort(comparator);
1054 // Fetch the default set of models for this collection, resetting the
1090 // **parse** converts a response into a list of models to be added to the
1096 // Create a new collection with an identical list of models as this one.
1098 return new this.constructor(this.models, {
1104 // Define how to uniquely identify models in the collection.
1113 this.models = []; property
1133 _removeModels: function(models, options) { argument
1135 for (var i = 0; i < models.length; i++) {
1136 var model = this.get(models[i]);
1140 this.models.splice(index, 1);
1184 // Sets need to update their indexes when models change ids. All other
1217 // Mix in each Underscore method as a proxy to `Collection#models`.
1218 addUnderscoreMethods(Collection, collectionMethods, 'models');
1229 // react to specific changes in the state of your models.
1392 // models to the server. You will be passed the type of request, and the
1397 // * Send up the models as XML instead of JSON.
1398 // * Persist models via WebSockets instead of Ajax.