Backbone.js Tutorial - 10 - (Views) Events (ok)

C:\Users\Administrator\Desktop\gulp\app.js
var theView = Backbone.View.extend({
initialize: function() {
this.render();
},
render: function() {
var template = _.template($("#ourTemplate").html(),{});
this.$el.html(template);
},
events: {
"click": "clicked"
},
clicked: function(event) {
console.log('clicked');
}
});
jQuery(document).ready(function($) {
var page = new theView({el: $("#div1")});
});

C:\Users\Administrator\Desktop\gulp\app.js
var theView = Backbone.View.extend({
initialize: function() {
this.render();
},
render: function() {
var template = _.template($("#ourTemplate").html(),{});
this.$el.html(template);
},
events: {
"click": "clicked",
"mouseover": "mouseover"
},
clicked: function(event) {
console.log('clicked');
},
mouseover: function(event) {
console.log('mouseover');
}
});
jQuery(document).ready(function($) {
var page = new theView({el: $("#div1")});
});
PreviousBackbone.js Tutorial - 9 - (Views) Using the Render Function (ok)NextBackbone.js Tutorial - 11 - Introduction to Collections (ok)
Last updated