I am new to backbone. I have a view called AbcView abc.js
var AbcView = Backbone.View.extend({ events: { "click" : "display", }, display: function(e){ console.log("hello"); alert("click function"); } });
Now I am passing this abc.js to another xyz.js file and calling it in another view using ListenTo.
xyz.js
var xyzView = Backbone.View.extend({ initialize: function(){ var AbcView = new AbcView (); this.lisenTo(AbcView, "click",this.display); }, render: function(){ var html = this.template(AbcView); this.$el.html(html); return this; }, display: function(e){ console.log("parent hello"); alert("parent display function"); } });
The abc.js click event triggers a penalty. But with the event xyz.js click does not fire.
This is the correct way to call listenTo.
source share