diff --git a/src/app.js b/src/app.js index cc87655..10359bf 100644 --- a/src/app.js +++ b/src/app.js @@ -1,9 +1,36 @@ +import Backbone from 'backbone'; +import $ from 'jquery'; + import Application from 'app/models/application'; import ApplicationView from 'app/views/application_view'; +import Rolodex from 'app/collections/rolodex'; +import RolodexView from 'app/views/rolodex_view'; + +var contactData = [ + { + name: "Yasmin", + phone: "555-5555", + email: "you_wish@gmail.com" + }, { + name: "Erin", + phone: "777-7777", + email: "oshkosh@yahoo.com" + } +]; var application = new Application(); var appView = new ApplicationView({ - el: '#application', - model: application + el: $('#application'), + model : application +}); + + +$(document).ready(function() { + var contactList = new Rolodex(contactData); + var contactListView = new RolodexView({ + el: ("#application"), + model: contactList + }); + contactListView.render(); }); diff --git a/src/app/collections/rolodex.js b/src/app/collections/rolodex.js index cc11371..6db126a 100644 --- a/src/app/collections/rolodex.js +++ b/src/app/collections/rolodex.js @@ -1,10 +1,13 @@ import Backbone from 'backbone'; +import Contact from 'app/models/contact' + const Rolodex = Backbone.Collection.extend({ // This Rolodex represents a collection of Contacts // and should include any methods or attributes // that are involved in working with more than one // Contact. + model: Contact }); export default Rolodex; diff --git a/src/app/models/application.js b/src/app/models/application.js index 45c60fe..2931272 100644 --- a/src/app/models/application.js +++ b/src/app/models/application.js @@ -1,7 +1,16 @@ import Backbone from 'backbone'; +// import ApplicationView from 'app/views/application_view' +import Rolodex from 'app/collections/rolodex' +import Contact from 'app/models/contact' + const Application = Backbone.Model.extend({ // This model represents the overall application. + // + // initialize: function() { + // console.log("Created new contactList"); + // this.staticContact = new Rolodex(contactData); + // } }); export default Application; diff --git a/src/app/models/contact.js b/src/app/models/contact.js index 395f247..59ffc05 100644 --- a/src/app/models/contact.js +++ b/src/app/models/contact.js @@ -3,6 +3,16 @@ 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: "Jane Doe", + phone: "(555)555-5555", + email: "jane_doe@gmail.com" + }, + + initialize: function() { + console.log("created a new contact for " + this.name); + } + }); export default Contact; diff --git a/src/app/views/application_view.js b/src/app/views/application_view.js index 8d3b235..2d91aeb 100644 --- a/src/app/views/application_view.js +++ b/src/app/views/application_view.js @@ -1,13 +1,55 @@ import Backbone from 'backbone'; +import _ from 'underscore'; +import $ from 'jquery'; + +import ContactView from 'app/views/contact_view'; +import Contact from 'app/models/contact'; + +// import RolodexView from 'app/views/contact_view'; const ApplicationView = Backbone.View.extend({ initialize: function() { - this.render(); - }, + // Compile a template to be shared between the contacts + // this.cardTemplate = _.template($('#tmpl-contact-card').html()); + // + // // Keep track of the