JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
<div id="content"></div>
JavaScript
var View = Backbone.View.extend({
template: '<button id="button1">button1</button><br><br><button class="button2">button2</button>',
render: function() {
$(this.el).html(this.template);
return $(this.el);
},
events: {
'click #button1': 'onClickButton1',
'click .button2': 'onClickButton2'
},
onClickButton1: function() {
alert('button1');
},
onClickButton2: function() {
alert('button2');
}
});
$(function() {
$('#content').html(new View().render());
});