0

I have a model and collection, when I create my collection I would like to fetch three models instead of all collections.

If I use collection.fetch() - if will fetch all objects, right now - I am fetching each model and then creating the collection, like this -

var model = new App.Model({ Id: 1 });
model.fetch().success(function() {
    var collection = new Collection(model);
});

(This is a simplistic version for one model, if I want to fetch multiple, I use $.when)

There is an official/better way for doing this? or I am at the good path?

2 Answers 2

1

I think you can get the models that you want from the original collection and put them in a temp collection. So you can fetch the temp collection once instead fetch each model one by one.

Sign up to request clarification or add additional context in comments.

Comments

0

After a little bit of thinking, I saw that my collections have many to one relation to my model. So I used backbone-relational to fetch all of this collections.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.