AI Features

Some Cleanup

Cleaning up our code by updating list view and controller files according to the previously made modifications in our project.

The triggers hash

Now that we’re using the triggers hash, let’s use it to clean up our code a bit. So far, we’ve got the following code:

List.Contact = Marionette.ItemView.extend({
tagName: "tr",
template: "#contact-list-item",
events: {
"click": "highlightName",
"click td a.js-show": "showClicked",
"click td a.js-edit": "editClicked",
"click button.js-delete": "deleteClicked"
},
// edited for brevity
showClicked: function(e){
e.preventDefault();
e.stopPropagation();
this.trigger("contact:show", this.model);
},
editClicked: function(e){
e.preventDefault();
e.stopPropagation();
this.trigger("contact:edit", this.model);
},
deleteClicked: function(e){
e.stopPropagation();
this.trigger("contact:delete", this.model);
},
// edited for brevity
});

Using a triggers hash, we can reduce ...

Ask