2012-09-25 21 views
0

我使用this.isNew我的收藏里和有一个问题,它看起来像下面:Backbonejs集URL 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' 
    } 
}); 

它提醒“集合”,而不是“全部显示”和‘新建项目’,然后我得到的错误‘类型错误:this.isNew是不是一个函数’

感谢,

回答