Tutorial by Examples

Backbone models describe how data is stored using JavaScript objects. Each model is a hash of fields called attributes and the behaviour of the model including validation is described by options. A model of Todo item in a TodoApp would be var ToDo = Backbone.Model.extend({ defaults: { assi...
var Vehicle = Backbone.Model.extend({ description: function () { return 'I have ' + this.get('wheels') + ' wheels'; } }); var Bicycle = Vehicle.extend({ defaults: { wheels: 2 } }); var Car = Vehicle.extend({ defaults: { wheels: 4 } })...
By default, the urlRoot property is not defined. This urlRoot property is used by the url method to create a relative URL where the model's resource would be located on the server. var User = Backbone.Model.extend({ urlRoot: '/api/users', // or urlRoot: function () { return '/...

Page 1 of 1