blob: f79bde24879112bab9b80704e129bc0676d01fc5 [file] [log] [blame]
Scott Baker7ee32a02014-07-13 09:52:15 -07001var ContactManager = new Marionette.Application();
2
3ContactManager.addRegions({
4 mainRegion: "#main-region"
5});
6
7ContactManager.Contact = Backbone.Model.extend({});
8
9ContactManager.ContactCollection = Backbone.Collection.extend({
10 model: ContactManager.Contact
11});
12
13ContactManager.ContactItemView = Marionette.ItemView.extend({
14 tagName: "li",
15 template: "#contact-list-item"
16});
17
18ContactManager.ContactsView = Marionette.CollectionView.extend({
19 tagName: "ul",
20 childView: ContactManager.ContactItemView
21});
22
23ContactManager.on("start", function(){
24 var contacts = new ContactManager.ContactCollection([
25 {
26 firstName: "Bob",
27 lastName: "Brigham",
28 phoneNumber: "555-0163"
29 },
30 {
31 firstName: "Alice",
32 lastName: "Arten",
33 phoneNumber: "555-0184"
34 },
35 {
36 firstName: "Charlie",
37 lastName: "Campbell",
38 phoneNumber: "555-0129"
39 }
40 ]);
41
42 var contactsView = new ContactManager.ContactsView({
43 collection: contacts
44 });
45
46 ContactManager.mainRegion.show(contactsView);
47});
48
49ContactManager.start();