jaydoubleyou
jaydoubleyou

Reputation: 342

backbone.js - fetch a list of models via Collection by a list of IDs

i'd like to fetch a bunch of models via a collection by a list of model IDs. My problem is that i have to fetch dozens of models at once. I don't want to put dozens over douzens of IDs into the URL when firing a GET request.

I'm thinking about a POST request. But can this be done via Collection?

Maybe this way: https://gist.github.com/2953670

I know i'm raping a POST/create request. Alternatively i have jQuery.post() in mind.

What is the better way?

Thanks in advance, JW

Upvotes: 0

Views: 1818

Answers (1)

Anthony Chua
Anthony Chua

Reputation: 1198

Everytime a model/collection does a sync call, it actually does return (this.sync || Backbone.sync).call.... This allows you to implement a custom sync for a specific model or collection.

var Equipment.Collection = Backbone.Collection.extend({ 
    ...

    "sync": urSync,

    ...
});

Upvotes: 1

Related Questions