Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Rolodex
Create a single-page application using Backbone that will track contact information for you about your friends!

Expand Down
4 changes: 4 additions & 0 deletions src/app/models/application.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Backbone from 'backbone';
import Contact from 'app/models/contact';

const Application = Backbone.Model.extend({
// This model represents the overall application.
initialize: function() {
this.contact = new Contact();
}
});

export default Application;
19 changes: 17 additions & 2 deletions src/app/models/contact.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
// When wave 1 is complete your application should:
//
// Have a Backbone Model subclass called Contact. This model should have these attributes:
// Name
// E-mail address
// Phone number
// Have a single instance of Contact created from static data.
// Have a Backbone View subclass called ContactView.
// Display a single contact card on the contact list. This contact card should:
// Be implemented by using Contact and ContactView together.
// Show the name only, no other contact details.

import Backbone from 'backbone';

const Contact = Backbone.Model.extend({
// This model should have the attributes for
// a single contact: name, phone number, and email.
defaults: {
name: "Bob",
email: "bob@bob.com",
phone: "555-555-555"
}
});

export default Contact;
5 changes: 5 additions & 0 deletions src/app/views/application_view.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import Backbone from 'backbone';
import ContactView from 'app/views/contact_view';

const ApplicationView = Backbone.View.extend({
initialize: function() {
this.render();
},

render: function() {
const card = new ContactView({
model: this.model.contact,
});
this.$('#contact-cards').append(card.render().$el);
return this;
}
});
Expand Down
9 changes: 9 additions & 0 deletions src/app/views/contact_view.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import _ from 'underscore';
import Backbone from 'backbone';

const ContactView = Backbone.View.extend({
initialize: function() {
this.template = _.template(Backbone.$('#tmpl-contact-card').html());
},

render: function() {
this.$el.html(this.template(this.model.attributes));
return this;
}
});

export default ContactView;