【发布时间】:2013-10-15 09:38:56
【问题描述】:
谁能帮助解决这个问题?我有嵌套数据,我试图在我的 Marionette/Backbone 模型的初始化事件中设置这些数据。这是一个例子:
{
"items": [
{
"name": "Coke",
"description": "Fizzy drink",
"price": [
{
"retail": 2.50,
"shop": 3.50
}
],
},
...
所以,我可以像这样在模型的初始化函数中获取这些数据:
...
initialize: function() {
this.name = this.get('name');
this.description = this.get('description');
}
为了得到价格,我试过了,例如:
this.price = this.get('price[0].shop');
...以及许多其他变体。
我的问题是,我如何从这个结构中获得价格?
价格将以标准模板结束,例如
非常感谢
【问题讨论】:
标签: backbone.js collections nested models marionette