Im currently trying to use a Promise to resolve fetching models from database. In the following was:
Promise.resolve(app.Departments.fetch()).then(function(response){
console.log(response);
this.$el.html( this.template( {depts: app.Departments.toJSON()} ));
this.$form = this.$('#form-employee');
this.$form.validator();
return this;
})
Consider everything is inside the render method and the method is inside a Backbone.View.extend({}) object. The problem is that inside the Promise.resolve() function the context of this is different from the context inside the View object which it throws an error not knowing what does this refers to. Is there anyway to pass to Promise.resolve the correct context of this?