backbone js event listener code example
Example 1: event listener javascript
const element = document.querySelector(".class__name");
element.addEventListener("click", () => {
console.log("clicked element");
});
Example 2: jquery event listener
$('element').on('event', function() {
});
$('element').click(function(){
});
$('element').hover(function(){
});
Example 3: backbone js event listener
var ViewName = Backbone.View.extend({
initialize: function(){
this.$el.on("eventName", this.functionName, this)
},
functionName: function(){
},
remove: function() {
this.$el.off("eventName", this.functionName);
Backbone.View.prototype.remove.apply(this, arguments);
}
});
Example 4: backbone js event listener
var ViewName = Backbone.View.extend({
initialize: function(){
this.$el.on("eventName", this.functionName, this)
},
functionName: function(){
}
});