Events in CompositeView
Learn how to use events to highlight rows in the tables created using CompositeViews in Marionette.
We'll cover the following...
Using events
As we saw in the previous lessons, we can define events and their associated handlers within views.
Let’s use this ability to toggle highlighting on the rows that get clicked by toggling Bootstrap’s warning
class to the appropriate tr
element:
Press + to interact
List.Contact = Marionette.ItemView.extend({tagName: "tr",template: "#contact-list-item",events: {"click": "highlightName"},highlightName: function(){this.$el.toggleClass("warning");}});
The events
object in lines 5–7 associates jQuery event listeners with handler functions. ...