-
Book Overview & Buying
-
Table Of Contents
Learning Yeoman
By :
The Backbone.Model class is used to extend application-specific domain methods and logic, which provide functionality to manage changes to data, and the ability to send CRUD (GET/PUT/POST/DELETE) operations on the server and dispatch many useful events.
For more information on Backbone.Model, visit http://goo.gl/f9Wj2l.
To bind to the model events, use the model.on('name', callback) function, which will trigger the callback when that event is invoked.
To create a new model, use the backbone:model subgenerator, open the terminal, and execute the following command to create a new post model:
$ yo backbone:model post
This command will create a new file named post.coffee located in the app/scripts/models directory; open the newly created model and add the following code:
define ['underscore', 'backbone'], (_, Backbone) ->
'use strict'
class PostModel extends Backbone.Model
idAttribute: '_id'
urlRoot: '/api/v2/learning-yeoman-ch3/posts'
defaults...
Change the font size
Change margin width
Change background colour