Why this scope is not working? Why do I need to make temp var in below code.
I have tried to render with this
but object is undefined. Though I have achieved the results but I do not understand why I need to temp variable named as that
.
var CategoryView = Backbone.View.extend({
template: require('hbs!./../templates/CategoryView'),
render: function () {
var that = this;
this.collection.fetch({
contentType: 'application/json',
type: 'GET',
success: function(categoryCollection) {
that.$el.html(that.template(categoryCollection.toJSON()));
}
});
return this;
}
});