Download Beginning Backbone.js by James Sugrue PDF
By James Sugrue
Read or Download Beginning Backbone.js PDF
- Advanced Perl Programming
- Beginning Node.js
Additional resources for Beginning Backbone.js
In cases where the id attribute has not been set and save is called, the model will invoke a create operation (HTTP POST) on the back-end REST service, while an update (HTTP PUT) operation will be used when the ID has been specified. This is a simple way of ensuring that a single save function can be used regardless of whether your model has been newly created or has been edited since last retrieved from the server. The save function can be called with no parameters or can take the set of attributes you want to persist to the server, along with an options hash that contains handlers for both success and error cases.
Get function. Recall that until a model has been synchronized with a back-end service, the cid attribute is used instead. get('name'): If no model matches the id or cid that is used as a parameter, this function returns undefined. at function, which accepts the index at which the model is present in the collection. If the collection is not sorted, the index parameter will refer to the insertion order. get('name')); } There is a more elegant utility function provided by Underscore that helps iterate through collections, namely, the forEach function.