model.urlRoot

urlRootmodel.urlRoot or model.urlRoot() Specify a urlRoot if you're using a model outside of a collection, to enable the default url function to generate URLs based on the model id. "[urlRoot]/id" Normally, you won't need to define this. Note that urlRoot may also be a function. var Book = Backbone.Model.extend({urlRoot : '/books'}); var solaris = new Book({id: "1083-lem-solaris"}); alert(solaris.url());

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

unsetmodel.unset(attribute, [options]) Remove an attribute by deleting it from the internal attributes hash. Fires a "change" event unless silent is passed as an option.

model.toJSON

toJSONmodel.toJSON([options]) Return a shallow copy of the model's attributes for JSON stringification. This can be used for persistence, serialization, or for augmentation before being sent to the server. The name of this method is a bit confusing, as it doesn't actually return a JSON string â but I'm afraid that it's the way that the JavaScript API for JSON.stringify works. var artist = new Backbone.Model({ firstName: "Wassily", lastName: "Kandinsky" }); artist.set({birthday: "Dec

model.sync

syncmodel.sync(method, model, [options]) Uses Backbone.sync to persist the state of a model to the server. Can be overridden for custom behavior.

model.set

setmodel.set(attributes, [options]) Set a hash of attributes (one or many) on the model. If any of the attributes change the model's state, a "change" event will be triggered on the model. Change events for specific attributes are also triggered, and you can bind to those as well, for example: change:title, and change:content. You may also pass individual keys and values. note.set({title: "March 20", content: "In his eyes she eclipses..."}); book.set("title", "A Scandal in Bohemia");

model.save

savemodel.save([attributes], [options]) Save a model to your database (or alternative persistence layer), by delegating to Backbone.sync. Returns a jqXHR if validation is successful and false otherwise. The attributes hash (as in set) should contain the attributes you'd like to change â keys that aren't mentioned won't be altered â but, a complete representation of the resource will be sent to the server. As with set, you may pass individual keys and values instead of a hash. If the mod

model.previousAttributes

previousAttributesmodel.previousAttributes() Return a copy of the model's previous attributes. Useful for getting a diff between versions of a model, or getting back to a valid state after an error occurs.

model.previous

previousmodel.previous(attribute) During a "change" event, this method can be used to get the previous value of a changed attribute. var bill = new Backbone.Model({ name: "Bill Smith" }); bill.on("change:name", function(model, name) { alert("Changed name from " + bill.previous("name") + " to " + name); }); bill.set({name : "Bill Jones"});

model.pick

pick