Answer the question
In order to leave comments, you need to log in
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
var ids = _.pluck(collection.models, 'id');
collection.fetch({
data: {
ids : ids.join(',')
}
});
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 questionAsk a Question
731 491 924 answers to any question