Marionette.js. View triggers

The view triggers attribute binds DOM events to Marionette View events that can be responded to at the view or parent level. For more information on events, see the events documentation. This section will just cover how to bind these events to views.

by marionettejs

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.radio/2.0.0/backbone.radio.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/3.0.0/backbone.marionette.js"></script>

JavaScript

const MyView = View.extend({
	template: _.template('<a href="">Show modal</a>'),
  triggers: {
    'click': 'link:clicked'
  },
  
  onLinkClicked() {
    event.preventDefault();
    console.log('Show the modal');
  }
});

const myRegion = new Region({ el: $('body') });
myRegion.show(new MyView());