Skip to content

Instantly share code, notes, and snippets.

@TomoyaShibata
Last active August 29, 2015 14:15
Show Gist options
  • Save TomoyaShibata/eca935c23ac290aad5af to your computer and use it in GitHub Desktop.
Save TomoyaShibata/eca935c23ac290aad5af to your computer and use it in GitHub Desktop.
Backbone.Collection に1つ以上の Model が格納できない問題を解決する ref: http://qiita.com/bps/items/fcd8d7456773852b9cce
var Collection = Backbone.collection.extend({
model: Backbone.Model.extend({ idAttribute: 'cid' });
});
var collection = new Collection(attrs);
var attrs = [
{ id: { shopId : 'hogeShop', humanId: 'TaroYamada' } },
{ id: { shopId : 'hogeShop', humanId: 'JiroTanaka' } }
];
new Backbone.Collection(attrs);
var attrs = [
{ id: { shopId : 'hogeShop', humanId: 'TaroYamada' } },
{ id: { shopId : 'hogeShop', humanId: 'JiroTanaka' } }
];
new Backbone.Collection(attrs, { model: Backbone.Model.extend({ idAttribute: 'cid' }) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment