A
A
Artem Komarov2014-10-23 12:13:19
JavaScript
Artem Komarov, 2014-10-23 12:13:19

How to request a part of a collection using the backbone?

Backend:
There is a /objects URL that returns a list of objects to add to the user's workspace. A backbone model and a collection of models are created, the URL is registered in it.
Task:
when requesting, send to the server a list of only those objects that are not yet on the workspace (for this, I need to pass the IDs of those already added in the request).
Question:
how do I change the URL to pass a list of IDs of the added objects? Or maybe there is some other architectural solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
personaljs, 2014-10-23
@m0sk1t

var ids = _.pluck(collection.models, 'id');
collection.fetch({
  data: {
    ids : ids.join(',')
}
});

K
Konstantin Kitmanov, 2014-10-23
@k12th

Collections url may have a method that generates the address. You have to cheat there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question