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")});
});

Last updated

Navigation

Lionel

@Copyright 2023