Whenever I create a new view object in this manner:
app.MyCollectionView = Backbone.View.extend({
el: "#my-element",
template: _.template($(#my-view-template).html()),
render: function(){
this.$el.append(this.template({
"myTemplateVar": this.html_string
}));
var html_string = "<p>Some stuff here</p>";
}
});
In the given code snippet, the issue arises with the variable "html_string". Despite its presence, it fails to have any impact on the rendering of the view, resulting in an empty "myTemplateVar". However, if "html_string" is defined as a parameter for the view, everything functions correctly. What could be causing this discrepancy?