WindowsMaker
WindowsMaker

Reputation: 3400

Backbone new view reflects old model data

My model:

var ListModel = Backbone.Model.extend({
        defaults:{
            title: "",
            items:new Array(),
        },
        initialize: function(){
        }
...

but for some reason when i do:

function createNew(){
    var m = new ListModel();
    console.log(m);
    [model items get modified somehow]
}
createNew()

createNew()

the output for the model.items are identical between the two models

Why is that?

Upvotes: 0

Views: 110

Answers (1)

WindowsMaker
WindowsMaker

Reputation: 3400

It appears that I need to do:

initialize: function(){
    this.set("items", new Array());
}

instead of doing it in default

Upvotes: 1

Related Questions