0
var Song = Backbone.Model.extend({
defaults: {
name: "Not specified",
artist: "Not specified"
},
initialize: function() {
document.write("Music is the answer");
},
url:function(){
return '/home/';
}
});
var Album = Backbone.Collection.extend({
model: Song
});
var song1 = new Song({
name: "How Bizarre",
artist: "OMC"
});
var song2 = new Song({
name: "Sexual Healing",
artist: "Marvin Gaye"
});
var song3 = new Song({
name: "Talk It Over In Bed",
artist: "OMC"
});
var myAlbum = new Album([song1, song2, song3]);
document.write(myAlbum.models); // [song1, song2, song3]
- 我如何發送
myAlbum.models
對象到我的服務。 - 我怎麼能提醒我的網址
你是什麼意思有:_ 「提醒我的網址」 _? – fguillen
重複? http://stackoverflow.com/questions/10782510/backbone-create-multiple-models-in-collection-serverside/10788855#10788855 – fguillen
同意@fguillen。這是做批量更新/保存的解決方案。 http://stackoverflow.com/questions/5014216/best-practice-for-saving-an-entire-collection – TYRONEMICHAEL