Step 2 - Contact Model
-
Add app.js file with main namespace
window.ContactManager = { Models: {}, Collections: {}, Views: {} };
-
Add models/contact.js with empty model:
ContactManager.Models.Contact = Backbone.Model.extend({ });
and to index.html:
<script src="app/js/models/contact.js"></script>
-
Show initialization, accessors, toJSON in console
-
Add defaults to contact model:
defaults: { name: null, tel: null, email: null, avatar: null }
-
Add random avatar generation:
initialize: function() { this.set('avatar', _.random(1, 15) + '.jpg'); }
-
Create some method and show in DevTools