When working with the guid
variable in the render()
function, I encountered a limitation where I could only pass it to the constructor. Here is an example of the code I used:
app.views.CompanyView = Backbone.View.extend({
el: '#company-view',
guid: '',
initialize: function (options) {
this.guid = options.guid;
},
render: function () {
var guid = this.guid;
}
});
To instantiate my view, I followed this pattern:
app.currentView = new app.views.CompanyView({guid: guid});
Subsequently, I attempted to pass the render()
function as a callback for usage:
function call(callback){
callback();
}
call(app.currentView.render);
Various attempts such as using this.guid
, options
, and this.options
resulted in the values being undefined
. Is there a method to transmit this variable to the render()
function without relying on its arguments or global variables? An illustrative example can be found in this JsFiddle link.