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);

view.$

$ (jQuery)view.$(selector) If jQuery is included on the page, each view has a $ function that runs queries scoped within the view's element. If you use this scoped jQuery function, you don't have to use model ids as part of your query to pull out specific elements in a list, and can rely much more on HTML class attributes. It's equivalent to running: view.$el.find(selector) ui.Chapter = Backbone.View.extend({ serialize : function() { return { title: this.$(".title").text(),

View

constructor / initializenew View([options]) There are several special options that, if passed, will be attached directly to the view: model, collection, el, id, className, tagName, attributes and events. If the view defines an initialize function, it will be called when the view is first created. If you'd like to create a view that references an element already in the DOM, pass in the element as an option: new View({el: existingElement}) var doc = documents.first(); new DocumentRow({ mod

update event

"update" (collection, options) â single event triggered after any number of models have been added or removed from a collection.

sync event

"sync" (model_or_collection, response, options) â when a model or collection has been successfully synced with the server.

sort event

"sort" (collection, options) â when the collection has been re-sorted.

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

router.route

routerouter.route(route, name, [callback]) Manually create a route for the router, The route argument may be a routing string or regular expression. Each matching capture from the route or regular expression will be passed as an argument to the callback. The name argument will be triggered as a "route:name" event whenever the route is matched. If the callback argument is omitted router[name] will be used instead. Routes added later may override previously declared routes. initialize: functi

router.navigate

navigaterouter.navigate(fragment, [options]) Whenever you reach a point in your application that you'd like to save as a URL, call navigate in order to update the URL. If you also wish to call the route function, set the trigger option to true. To update the URL without creating an entry in the browser's history, set the replace option to true. openPage: function(pageNumber) { this.document.pages.at(pageNumber).open(); this.navigate("page/" + pageNumber); } # Or ... app.navigate("help

Router.extend

extendBackbone.Router.extend(properties, [classProperties]) Get started by creating a custom router class. Define actions that are triggered when certain URL fragments are matched, and provide a routes hash that pairs routes to actions. Note that you'll want to avoid using a leading slash in your route definitions: var Workspace = Backbone.Router.extend({ routes: { "help": "help", // #help "search/:query": "search", // #search/kiwis "search/:query/p