JSFiddle - React, Tailwind, and code Playground
by Cody Lindley
HTML
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/jquery-2.0.2.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/lodash.underscore.js"></script>
<script src="https://dl.dropboxusercontent.com/u/2026291/backbone/backbone.js"></script>
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
<div id="myView"></div>
CSS
iframe {
height:263px !important;
}
JavaScript
var MyView = Backbone.View.extend({
sayHi: function () {console.log('hi');},
render: function () {
this.$el.html('<button>sayHi</button>');
$('body').append(this.el);
},
initialize:function(){this.render();}
});
var myViewInstance = new MyView(); //create view
myViewInstance.events = {'click button':'sayHi'}; //set events object
//have to call delegateEvents because we setup the events after the view was created
myViewInstance.delegateEvents();
//Now the events should work, can call undelegatedEvents to remove