Skip to content

Commit

Permalink
User CompositeView in contacts view
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytroyarmak committed Feb 5, 2014
1 parent ae302b0 commit f8493e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ http://dmytroyarmak.github.io/codeangels-marionette-introduction
- [Step 0 - Initialization of project](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-0)
- [Step 1 - Install Marionette.js](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-1)
- [Step 2 - Use ItemView](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-2)
- [Step 3 - Use CollectionView](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-3)
- [Step 4 - Use CompositeView](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-4)
- [Step 3 - Use CompositeView](https://github.com/dmytroyarmak/marionette-contact-manager/releases/tag/step-3)

## Previous lesson
https://github.com/dmytroyarmak/backbone-contact-manager
4 changes: 0 additions & 4 deletions app/js/views/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ ContactManager.Views.Contact = Marionette.ItemView.extend({
'click .delete-contract': 'onClickDelete'
},

modelEvents: {
'remove': 'close'
},

onClickDelete: function(e) {
e.preventDefault();
this.model.collection.remove(this.model);
Expand Down
20 changes: 4 additions & 16 deletions app/js/views/contacts.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
ContactManager.Views.Contacts = Backbone.View.extend({
template: _.template($('#tpl-contacts').html()),

renderOne: function(contact) {
var itemView = new ContactManager.Views.Contact({model: contact});
this.$('.contacts-container').append(itemView.render().$el);
},

render: function() {
var html = this.template();
this.$el.html(html);

this.collection.each(this.renderOne, this);

return this;
}
ContactManager.Views.Contacts = Marionette.CompositeView.extend({
template: '#tpl-contacts',
itemView: ContactManager.Views.Contact,
itemViewContainer: '.contacts-container'
});

0 comments on commit f8493e3

Please sign in to comment.