So I am calling a function within a view when a user clicks a button. This function requires a callback function. I have the callback defined within the same view. When The callback is called I want to render the current view with the additional info just obtained. However it seems like you lose scope within the callback function so that I get an error when calling this.render(); Saying "global object has not method render". So 'this' now refers to the window object. How do I retain scope within my view? So here is an example of what Im talking about.
var profileView = Parse.View.extend({
events: {
"click #scan_item": "scanItem"
},
scanItem: function(){
ScanItem(callback);
},
callback: function(info){
this.render(info);
},
render: function(info){
$(this.el).html(this.template({info: info}));
return this;
}
});