In my Backbone view, I have my main view being rendered using the Backbone render function.
this.setElement($(".prodDetailContainer"));
this.$el.html(this.templateDesktop(this.dataSet.toJSON()));
this refers to the backbone view here. I'm setting the el to the class where the complied template needs to be attached. When the view completely renders, the Events are attached fine to this rendered template.
My issue is I'm also rendering other templates in a separate function in the BB view as
$(".attachDetails").html(this.prodDetailsTemplate(selAgg.toJSON()));
Now, for this above prodDetailsTemplate, I'm unable attach any Events using
BB events
events: {
"click .future-inv" : "changeGlyfIcon"
},
The class future-inv lies inside the prodDetailsTemplate. Only if I use the backbone el, the events are getting registered. Is there any way to have the events attached to both the templates?
Any help is really appreciated.
Adding the sentence
$(".attachDetails .future-inv").click(changeGlyfIcon);after$(".attachDetails").html(this.prodDetailsTemplate(selAgg.toJSON()));Check if that works??