Permalink
Browse files

display contacts as unordered list

  • Loading branch information...
davidsulc committed Jun 28, 2014
1 parent a5a36d3 commit a7723dfd04ea5b4523fc0a44b33da2bde553ed5b
Showing with 33 additions and 11 deletions.
  1. +33 −11 index.html
View
@@ -23,7 +23,7 @@
</div>
</div>
<script type="text/template" id="contact-template">
<script type="text/template" id="contact-list-item">
<p><%- firstName %> <%- lastName %></p>
</script>
@@ -38,8 +38,18 @@
ContactManager.Contact = Backbone.Model.extend({});
ContactManager.ContactView = Marionette.ItemView.extend({
template: "#contact-template"
ContactManager.ContactCollection = Backbone.Collection.extend({
model: ContactManager.Contact
});
ContactManager.ContactItemView = Marionette.ItemView.extend({
tagName: "li",
template: "#contact-list-item"
});
ContactManager.ContactsView = Marionette.CollectionView.extend({
tagName: "ul",
childView: ContactManager.ContactItemView
});
ContactManager.on("before:start", function(){
@@ -55,17 +65,29 @@
});
ContactManager.on("start", function(){
var alice = new ContactManager.Contact({
firstName: "Alice",
lastName: "Arten",
phoneNumber: "555-0184"
});
var contacts = new ContactManager.ContactCollection([
{
firstName: "Bob",
lastName: "Brigham",
phoneNumber: "555-0163"
},
{
firstName: "Alice",
lastName: "Arten",
phoneNumber: "555-0184"
},
{
firstName: "Charlie",
lastName: "Campbell",
phoneNumber: "555-0129"
}
]);
var aliceView = new ContactManager.ContactView({
model: alice
var contactsView = new ContactManager.ContactsView({
collection: contacts
});
ContactManager.regions.main.show(aliceView);
ContactManager.regions.main.show(contactsView);
});
ContactManager.start();

0 comments on commit a7723df

Please sign in to comment.