我有什么应该是非常简单的。我创建了一个新的集合,并且我想将它传递给一个渲染器并将集合模型添加到页面中。backbone.js集合没有响应。每个
get_results: function(){ $.getJson(this.url,function(response){ this.search_results = new Kitchon.Collections.searchList(response); console.log(this.search_results); this.search_results.each(this.render_match); } }, render_match: function(model){ console.log(model) },
这将返回一个错误
Uncaught TypeError: undefined is not a function
我的收藏有一个普通的结构
_byCid: Object _byId: Object _onModelEvent: function() { [native code] } _removeReference: function() { [native code] } length: 7 models: Array[7] __proto__: o
我已经试过许多事情,但有一点是伸出了也许我不得不通过 this.search_results.models.each(this.render_match);
因为这是实际的阵列,但如果我这样做,我得到一个Uncaught typeError: Object [object Object],[object Object],...
谢谢汤姆,我知道这会以某种方式迷失在'这个',但我不知道如何得到这个工作。来自耶胡达的文章是一个很好的补充。搜索“this”并取回相关结果很困难。 – pedalpete 2012-01-15 13:04:56