下面是我用(FacetModels)填充我的收藏
如何访问 AvailableValues[] 数组
“FacetModels”:[ { “FacetDisplayLabel”:null,“SelectedValues”:[],“AvailableValues”:[],“UnknownResults”:0,“ActionURI”:null,“FacetGroupName”:“Category”,“FacetGroupFriendlyId”: "SourceCategory", "FacetGroupOrder":10, "AllowSuggestions":false },
这是我的观点,你会看到我只能访问 FacetModels 数组,我需要能够传递 FacetModels[0].AvailableValues.Name 以便我可以显示每个类别名称
CategoryListItemView = Backbone.View.extend({
tagName: "li",
className: "category",
initialize: function (options) {
this.template = _.template( $("#categorylist_template").html());
},
render: function () {
var category = this.model
console.log(category);
console.log(this.model.toJSON());
$(this.el).html(this.template(this.model.toJSON()));
return this;
}
});
从控制台显示
a.Model {cid: "c2", attributes: Object, collection: r, _sharing: false, _previousAttributes: Object...} _sharing: false _events: Object _pending: false _previousAttributes: Object attributes: Object ActionURI: null AllowSuggestions: false数组 [8] 0:对象 ActionURI:“/api/search?firstname=thomas&firstname_variants=true&lastname=smith®ion=all&sourcecategory=armed%20forces%20utf0026%20conflict”计数:8943 DisplayLabel:“武装部队与冲突”IsUnknown:假名称:“武装部队与冲突” 原型:对象 1:对象 2:对象 3:对象 4:对象 5:对象 6:对象 7:对象长度:8 原型:Array[0] FacetDisplayLabel:空 FacetGroupFriendlyId:“SourceCategory”FacetGroupName:“Category” " FacetGroupOrder:10 SelectedValues:数组 [0] UnknownResults:0原型:对象已更改:对象 cid:“c2”集合:r 原型:对象