Tomer Lichtash
Tomer Lichtash

Reputation: 9252

Adding new data to collection in Backbone.js

I've fetched a Backbone collection, and now I want to fetch another data bulk, and add it to the existing collection. I've tried adding add: true to the fetch command, yet nothing seems to add. The model data is replaced with the new data.

I'm pretty sure I'm missing out on a basic issue. Help? Thanks.

Upvotes: 1

Views: 1463

Answers (1)

Typo Johnson
Typo Johnson

Reputation: 6044

One untested possibility :

people.reset( people.toArray().concat( newPeople));

But this isn't the backbone way. I would use Kennis' suggestion

fetch( {add:true});

Do you have any event handlers resetting the collection?

Upvotes: 2

Related Questions