如何默认检索 Backbone.js 中第一个模型的详细信息?
我想默认显示 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();
这方面的任何方向都会非常有帮助。
干杯!
I would like to display the details of the first model in Backbone by default, How can I go about this?
this.wineList = new WineCollection();
this.wineList.fetch();
After retrieving the value i would like to display the first model. To retrieve model details given its id, my code looks like this -
this.wine = this.wineList.get(id);
this.wineView = new WineView({model: this.wine});
this.wineView.render();
Any direction in this regard will be very helpful.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解您的问题,那么您正在寻找的是 at 方法 http://documentcloud。 github.com/backbone/#Collection-at
If I correctly understand your question, what you are looking for is the at method http://documentcloud.github.com/backbone/#Collection-at