我想默认显示Backbone中第一个模型的细节,我该如何解决这个问题?
this.wineList = new WineCollection();
this.wineList.fetch();
检索值后,我想显示第一个模型。要根据其ID检索模型详细信息,我的代码如下所示 -
this.wine = this.wineList.get(id);
this.wineView = new WineView({model: this.wine});
this.wineView.render();
这方面的任何方向都会非常有帮助。
干杯!
答案 0 :(得分:1)
如果我正确理解您的问题,您要找的是方法http://documentcloud.github.com/backbone/#Collection-at
this.wine = this.wineList.at(0);