Skip to content

anonymous /gist:2953670
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Backbone.js Collection fetchMany()
var Equipment = {};
Equipment.Model = Backbone.Model.extend({
urlRoot: 'equipment',
defaults: {
//...
}
});
Equipment.Collection = Backbone.Collection.extend({
url: 'equipment/list',
model: Equipment.Model,
fetchMany: function(id_list) {
var that = this;
Backbone.sync('create', new Backbone.Model({id_list: id_list}), {
url: that.url,
success: function(response_data) {
var models = [];
for (i=0; i<response_data.length; i++) {
models.push(new that.model(response_data[i]));
}
that.reset(models);
return true;
},
error: function() {
// handle error
}
});
}
});
var my_equipment_list = new Equipment.Collection();
my_equipment_list.fetchMany([12, 345, 234, 55, 23]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.