使用主幹我可以fetch
集合像下面並呈現每個記錄的骨幹網查看:骨幹JS手柄保存模型?
Person = Backbone.Model.extend({});
var PersonCollection = Backbone.Collection.extend({
model: Person,
url: '/home/people/'
});
當我旋轉起來使用骨幹象下面這樣一個新的人,是不是應該已經處理.save ()功能發佈到上面集合中定義的URL?
var p = new Person({ Name: 'Andrew', Age: 24 });
p.save();
// Uncaught Error: A 'url' property or function must be specified
// I thought it was supposed to use the Collection's URL?
// I can get around this by explicitly setting p.URL but doesn't seem right
當您依賴收集URL時,必須將您的Person包含在該收集中,然後才能發出保存...否則骨幹網無法知道該網址是什麼。 – Julien 2011-05-05 20:50:55
你意識到你可以在你的'Model.extend'調用中設置'collection',它會從集合中獲得'url' – Raynos 2011-06-14 21:42:21