view.el

elview.el All views have a DOM element at all times (the el property), whether they've already been inserted into the page or not. In this fashion, views can be rendered at any time, and inserted into the DOM all at once, in order to get high-performance UI rendering with as few reflows and repaints as possible. this.el can be resolved from a DOM selector string or an Element; otherwise it will be created from the view's tagName, className, id and attributes properties. If none are set, thi

Backbone.on

onobject.on(event, callback, [context])Alias: bind Bind a callback function to an object. The callback will be invoked whenever the event is fired. If you have a large number of different events on a page, the convention is to use colons to namespace them: "poll:start", or "change:selection". The event string may also be a space-delimited list of several events... book.on("change:title change:author", ...); Callbacks bound to the special "all" event will be triggered when any event occurs

collection.reset

resetcollection.reset([models], [options]) Adding and removing models one at a time is all well and good, but sometimes you have so many models to change that you'd rather just update the collection in bulk. Use reset to replace a collection with a new list of models (or attribute hashes), triggering a single "reset" event on completion, and without triggering any add or remove events on any models. Returns the newly-set models. For convenience, within a "reset" event, the list of any previou

model.validate

validatemodel.validate(attributes, options) This method is left undefined and you're encouraged to override it with any custom validation logic you have that can be performed in JavaScript. By default save checks validate before setting any attributes but you may also tell set to validate the new attributes by passing {validate: true} as an option. The validate method receives the model attributes as well as any options passed to set or save. If the attributes are valid, don't return anythin

collection.last

last

collection.reject

reject

collection.shift

shiftcollection.shift([options]) Remove and return the first model from a collection. Takes the same options as remove.

model.escape

escapemodel.escape(attribute) Similar to get, but returns the HTML-escaped version of a model's attribute. If you're interpolating data from the model into HTML, using escape to retrieve attributes will prevent XSS attacks. var hacker = new Backbone.Model({ name: "<script>alert('xss')</script>" }); alert(hacker.escape('name'));

model.clear

clearmodel.clear([options]) Removes all attributes from the model, including the id attribute. Fires a "change" event unless silent is passed as an option.

view.delegateEvents

delegateEventsdelegateEvents([events]) Uses jQuery's on function to provide declarative callbacks for DOM events within a view. If an events hash is not passed directly, uses this.events as the source. Events are written in the format {"event selector": "callback"}. The callback may be either the name of a method on the view, or a direct function body. Omitting the selector causes the event to be bound to the view's root element (this.el). By default, delegateEvents is called within the View'