JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<div id="MyDiv"></div>
<div id="MyDiv2"></div>
JavaScript
$( document ).ready( function () {
// Create your actual object here
var dispatcher = _.clone( Backbone.Events );
var View = Backbone.View.extend( {
initialize : function ( options ) {
dispatcher.on( 'close', this.close, this );
},
close : function () {
console.log( this.el.id );
}
} );
var Some_Kind_Of_View = View.extend( {
initialize : function ( options ) {
View.prototype.initialize.apply( this, arguments );
// ...
}
} );
var view1 = new View( {
el : $( "#MyDiv" )[0],
} );
var view2 = new Some_Kind_Of_View( {
el : $( "#MyDiv2" )[0]
} );
dispatcher.trigger( 'close' );
} );