我在我的收藏中使用 this.isNew 时遇到问题,它看起来如下所示:
window.MyModel = Backbone.Model.extend({
idAttribute: "_id",
});
window.MyModelList = Backbone.Collection.extend({
alert('Collection');
model: MyModel,
url: function() {
if (this.isNew()) {
alert('show all');
// will ask the server to show all items
return 'api/site/showall'
} else {
alert('create new item');
// will ask the server to create new item
return 'api/site/new'
}
});
它提醒“集合”而不是“显示全部”和“创建新项目”然后我收到错误“TypeError:this.isNew is not a function”
谢谢,