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

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.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'; } });

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.

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.without

without

Backbone.noConflict

Backbone.noConflictvar backbone = Backbone.noConflict(); Returns the Backbone object back to its original value. You can use the return value of Backbone.noConflict() to keep a local reference to Backbone. Useful for embedding Backbone on third-party websites, where you don't want to clobber the existing Backbone. var localBackbone = Backbone.noConflict(); var model = localBackbone.Model.extend(...);

model.keys

keys

View.extend

extendBackbone.View.extend(properties, [classProperties]) Get started with views by creating a custom view class. You'll want to override the render function, specify your declarative events, and perhaps the tagName, className, or id of the View's root element. var DocumentRow = Backbone.View.extend({ tagName: "li", className: "document-row", events: { "click .icon": "open", "click .button.edit": "openEditDialog", "click .button.delete": "destroy" }, ini

router.routes

routesrouter.routes The routes hash maps URLs with parameters to functions on your router (or just direct function definitions, if you prefer), similar to the View's events hash. Routes can contain parameter parts, :param, which match a single URL component between slashes; and splat parts *splat, which can match any number of URL components. Part of a route can be made optional by surrounding it in parentheses (/:optional). For example, a route of "search/:query/p:page" will match a fragme