Reputation: 50362
To set the data within a Backbone collection:
var someList = ['a', 'b', 'c'];
collection.reset({models:someList});
Is there a way to do this with a model
without having to call set()
on every single property?
Example
var pop_star = {
first_name: "Stacey",
last_name: "Ferguson"
}
// There is no "reset()" function on a model, but is there something like it?
model.reset(pop_star);
Thanks!
Upvotes: 1
Views: 1479
Reputation: 38772
Actually is the Model.set() what you're looking for. It can receive a hash
and it will update only the attributes into the hash.
model.set(pop_star);
Upvotes: 4