Getting Started with Backbone.js Models

Creating an Initialize Method

The Sales Team data that you see was rendered using JSON data that was hard-coded into the JavaScript code.

Use the form below to add a new sales person. Notice that for any field you leave blank, the default value defined in our model constructor is used (i.e. "John", "Smith", and "0").

NOTE: Each time a new SalesPerson item is created, a green message flashes in the upper-left-hand corner of the browser. When the page loads, there are four. As you manually add new SalesPerson items, a green message will flash, showing the model data. All of this is made possible by the SalesPerson constructor's initialize method.

Add a New Salesperson