Reputation: 525
Is there any options
for set
method or any other way to replace the current attributes of the model with ones provided?
Here is what I want:
var instance = new Backbone.Model();
instance.set({foo: 1});
instance.set({bar: 2}, {replace: true}); //just for example
console.log(instance.toJSON()); //returns {bar: 2}
Upvotes: 2
Views: 964
Reputation: 4721
If you want to clear just one attribute, you can use
instance.unset('foo').set({bar:2})
Upvotes: 0
Reputation: 14225
I guess you are looking for this: http://backbonejs.org/#Model-clear
instance.clear().set({bar: 2});
Upvotes: 2