...

/

Solution: Events in CompositeView

Solution: Events in CompositeView

Follow step-by-step instructions to use events for displaying user information in Marionette.

Defining a click event handler for generating an alert

To achieve the desired functionality, we need to have a click event handler for the td selector:

Press + to interact
List.Contact = Marionette.ItemView.extend({
tagName: "tr",
template: "#contact-list-item",
events: {
"click": "highlightName",
"click td": "alertCellText"
},
highlightName: function(e){
this.$el.toggleClass("warning");
},
alertCellText: function(e){
alert($(e.target).text());
}
});

We define the ...