model.fetch

fetchmodel.fetch([options]) Merges the model's state with attributes fetched from the server by delegating to Backbone.sync. Returns a jqXHR. Useful if the model has never been populated with data, or if you'd like to ensure that you have the latest server state. Triggers a "change" event if the server's state differs from the current attributes. fetch accepts success and error callbacks in the options hash, which are both passed (model, response, options) as arguments. // Poll every 10 sec

model.get

getmodel.get(attribute) Get the current value of an attribute from the model. For example: note.get("title")

model.hasChanged

hasChangedmodel.hasChanged([attribute]) Has the model changed since its last set? If an attribute is passed, returns true if that specific attribute has changed. Note that this method, and the following change-related ones, are only useful during the course of a "change" event. book.on("change", function() { if (book.hasChanged("title")) { ... } });

model.has

hasmodel.has(attribute) Returns true if the attribute is set to a non-null or non-undefined value. if (note.has("title")) { ... }

model.destroy

destroymodel.destroy([options]) Destroys the model on the server by delegating an HTTP DELETE request to Backbone.sync. Returns a jqXHR object, or false if the model isNew. Accepts success and error callbacks in the options hash, which will be passed (model, response, options). Triggers a "destroy" event on the model, which will bubble up through any collections that contain it, a "request" event as it begins the Ajax request to the server, and a "sync" event, after the server has successfull

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

extendBackbone.Model.extend(properties, [classProperties]) To create a Model class of your own, you extend Backbone.Model and provide instance properties, as well as optional classProperties to be attached directly to the constructor function. extend correctly sets up the prototype chain, so subclasses created with extend can be further extended and subclassed as far as you like. var Note = Backbone.Model.extend({ initialize: function() { ... }, author: function() { ... }, coordi

model.cid

cidmodel.cid A special property of models, the cid or client id is a unique identifier automatically assigned to all models when they're first created. Client ids are handy when the model has not yet been saved to the server, and does not yet have its eventual true id, but already needs to be visible in the UI.

model.clone

clonemodel.clone() Returns a new instance of the model with identical attributes.

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.