Skip to content

Field is not computed when model is created with an empty hash #22

Description

@blikblum

Tested with backbone 1.1.2
In the example below, m.get('test') returns undefined
http://jsfiddle.net/N4zh4/1/
if i create the model with var m = new MyModel({x: 2}); it works

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'));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions