Last active
August 29, 2015 14:15
-
-
Save TomoyaShibata/eca935c23ac290aad5af to your computer and use it in GitHub Desktop.
Backbone.Collection に1つ以上の Model が格納できない問題を解決する ref: http://qiita.com/bps/items/fcd8d7456773852b9cce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Collection = Backbone.collection.extend({ | |
model: Backbone.Model.extend({ idAttribute: 'cid' }); | |
}); | |
var collection = new Collection(attrs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
id: { | |
shopId : 'hogeShop', | |
humanId: 'TaroYamada' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var attrs = [ | |
{ id: { shopId : 'hogeShop', humanId: 'TaroYamada' } }, | |
{ id: { shopId : 'hogeShop', humanId: 'JiroTanaka' } } | |
]; | |
new Backbone.Collection(attrs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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