Feature: Delete a project

Let's add a delete button to our form for the feature Delete a project.

Let's make a change to ProjectView and add a new event to the events hash, called delete, which calls the delete method. We add a delete method, which destroys the model and removes ProjectView. We then call repository, removing RepositoryListView.

    events: {
      ...
      "click button.delete": "delete",
    },

    delete: function () {
      this.model.destroy();
      this.remove();
      this.repository({editMode:false});
    },

Let's make a change to ProjectListView and add a collection event handler to initialize. The event handler calls the remove method when an item is removed. The remove method grabs the model's attributes and searches the Projects collection, removing the item when ...

Get Advanced Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.