model.chain

chain

model.url

urlmodel.url() Returns the relative URL where the model's resource would be located on the server. If your models are located somewhere else, override this method with the correct logic. Generates URLs of the form: "[collection.url]/[id]" by default, but you may override by specifying an explicit urlRoot if the model's collection shouldn't be taken into account. Delegates to Collection#url to generate the URL, so make sure that you have it defined, or a urlRoot property, if all models of th

model.changedAttributes

changedAttributesmodel.changedAttributes([attributes]) Retrieve a hash of only the model's attributes that have changed since the last set, or false if there are none. Optionally, an external attributes hash can be passed in, returning the attributes in that hash which differ from the model. This can be used to figure out which portions of a view should be updated, or what calls need to be made to sync the changes to the server.

collection.unshift

unshiftcollection.unshift(model, [options]) Add a model at the beginning of a collection. Takes the same options as add.

collection.remove

removecollection.remove(models, [options]) Remove a model (or an array of models) from the collection, and return them. Each model can be a Model instance, an id string or a JS object, any value acceptable as the id argument of collection.get. Fires a "remove" event for each model, and a single "update" event afterwards, unless {silent: true} is passed. The model's index before removal is available to listeners as options.index.

view.$el

$elview.$el A cached jQuery object for the view's element. A handy reference instead of re-wrapping the DOM element all the time. view.$el.show(); listView.$el.append(itemView.el);

Collection.extend

extendBackbone.Collection.extend(properties, [classProperties]) To create a Collection class of your own, extend Backbone.Collection, providing instance properties, as well as optional classProperties to be attached directly to the collection's constructor function.

collection.url

urlcollection.url or collection.url() Set the url property (or function) on a collection to reference its location on the server. Models within the collection will use url to construct URLs of their own. var Notes = Backbone.Collection.extend({ url: '/notes' }); // Or, something more sophisticated: var Notes = Backbone.Collection.extend({ url: function() { return this.document.url() + '/notes'; } });

model.defaults

defaultsmodel.defaults or model.defaults() The defaults hash (or function) can be used to specify the default attributes for your model. When creating an instance of the model, any unspecified attributes will be set to their default value. var Meal = Backbone.Model.extend({ defaults: { "appetizer": "caesar salad", "entree": "ravioli", "dessert": "cheesecake" } }); alert("Dessert will be " + (new Meal).get('dessert')); Remember that in JavaScript, objects are passe

collection.comparator

comparatorcollection.comparator By default there is no comparator for a collection. If you define a comparator, it will be used to maintain the collection in sorted order. This means that as models are added, they are inserted at the correct index in collection.models. A comparator can be defined as a sortBy (pass a function that takes a single argument), as a sort (pass a comparator function that expects two arguments), or as a string indicating the attribute to sort by. "sortBy" comparato