0
您好我有從backbonejs的集合響應是訪問像獲得從對象數組骨幹模型
this.collection.models
並返回長度爲7的陣列 - 每個具有其內部的模型。
我嘗試過這個陣列進行搜索,並獲得相匹配
_id: Xmas
的模型,但每次我嘗試做我的錯誤
Object [object Array] has no method 'get'
誰能幫助!
您好我有從backbonejs的集合響應是訪問像獲得從對象數組骨幹模型
this.collection.models
並返回長度爲7的陣列 - 每個具有其內部的模型。
我嘗試過這個陣列進行搜索,並獲得相匹配
_id: Xmas
的模型,但每次我嘗試做我的錯誤
Object [object Array] has no method 'get'
誰能幫助!
,你可以嘗試一下本作迭代和獲取價值
_(collection.models).each(function(t){
//console.log("loop Model"+t)
t.get("title")
enter your required logic here
}, this);
你應該收集來的工作,而不是其內部陣列模式,那麼你可以使用收集代理下劃線方法,例如:
var xmasModel;
xmasModel = this.collection.find(function(item) {
return item.get("_id") == "Xmas"
})
你是否在模型數組上應用get方法? – muneebShabbir 2013-03-13 04:01:37