使用主干我可以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