<!DOCTYPE html>
<html>
<head>
<title>Backbone Example</title>
<link rel="stylesheet" href="lib\css\todos.css" />
<script src="lib/js/jquery-1.9.1.js"></script>
<script src="lib/js/underscore.js"></script>
<script src="lib/js/backbone.js"></script>
<script src="app.js"></script>
<script type="text/template" id="ourTemplate">
<button id="btnClick">Click Me</button>
</script>
</head>
<body>
<div id="div1"></div>
</body>
</html>
jQuery(document).ready(function($) {
var theView = Backbone.View.extend({
el: "#div1",
template: $("#ourTemplate").html(),
initialize: function() {
this.render();
},
events: {
"click #btnClick": "onClick"
},
onClick: function () {
console.log('OnClick')
},
render: function() {
var template = _.template(this.template);
this.$el.html(template);
return this;
}
});
var page = new theView();
});