Reputation: 4944
var View = Backbone.View.extend({
id: 'foobar',
param: {
x: this.id // Will be "undefined"
}
});
Is there any way making use of this
, that can make this.param.x
pointing to, or has the same value with this.id
?
Upvotes: 0
Views: 113
Reputation: 19821
Use something like that,
var View = Backbone.View.extend({
id: 'foobar',
initialize: function () {
this.param = { x: this.id };
}
});
Upvotes: 1
Reputation: 707258
You can't use the object's this
in a static declaration. You can set that value in a method call or in the constructor with code, but not in a static declaration.
Upvotes: 3