var MyModel = Backbone.Model.extend({
initialize: function () {
this.computedFields = new Backbone.ComputedFields(this);
},
computed: {
test: {
get: function () {
console.log('get');
return 5;
}
}
}
});
var m = new MyModel({});
console.log(m.get('test'));
Tested with backbone 1.1.2
In the example below,
m.get('test')returns undefinedhttp://jsfiddle.net/N4zh4/1/
if i create the model with
var m = new MyModel({x: 2});it works