Skip to content

Commit

Permalink
Add new contact on form submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytroyarmak committed Feb 3, 2014
1 parent 0eba535 commit 7b7739a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ window.ContactManager = {
router.on('route:newContact', function() {
var newContactForm = new ContactManager.Views.ContactForm();

newContactForm.on('form:submitted', function(attrs) {
attrs.id = contacts.isEmpty() ? 1 : (_.max(contacts.pluck('id')) + 1);
contacts.add(attrs);
router.navigate('contacts', true);
});

$('.main-container').html(newContactForm.render().$el);
});

Expand Down

0 comments on commit 7b7739a

Please sign in to comment.