JSFiddle - React, Tailwind, and code Playground
by Aubrey Taylor
HTML
<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/jquery/3.0.0-beta1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.marionette/2.4.4/backbone.marionette.min.js"></script>
JavaScript
var View = Marionette.ItemView.extend({
template: false,
className: "view-view",
constructor: function(options) {
this.listenTo(this, "render", this._onRender.bind(this));
this.listenTo(this, "custom:event", this._onCustomEvent.bind(this));
Marionette.ItemView.prototype.constructor.call(this, options);
},
initialize: function(options) {
this.dispatchCustomEvent();
},
dispatchCustomEvent: function() {
this.triggerMethod("custom:event", this);
},
_onRender: function() {
console.log("onRender fired");
},
_onCustomEvent: function() {
console.log("onCustomEvent fired");
}
});
var view = new View();
view.render();