我尝试Ember.js与Ember数据,和我有以下应用程序定义:烬数据DS.RESTAdapter导致类型错误
window.App = Ember.Application.create()
App.store = DS.Store.create
revision: 4
adapter: DS.RESTAdapter.create { bulkCommit: false }
App.Source = DS.Model.extend
# options
primaryKey: '_id'
# fields
name: DS.attr 'string'
raw_text: DS.attr 'string'
App.sourcesController = Ember.ArrayProxy.create
content: App.store.findAll App.Source
App.ListSourcesView = Ember.View.extend
templateName: 'app/templates/sources/list'
sourcesBinding: 'App.sourcesController'
该模板看起来是这样的:
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{{#each sources}}
{{view App.ShowSourceView sourceBinding="this"}}
{{/each}}
</tbody>
</table>
当我尝试在我的页面中加载App.ListSourcesView
时,在ember-data.js中出现错误:Uncaught TypeError: Cannot read property 'map' of undefined
。
我不知道我做错了什么,在这种情况下阅读源代码并没有帮助我的困惑。有没有人遇到过这种情况,或者可以告诉我我定义/没有正确定义的内容?
我为您的代码创建了一个JSFiddle,它的工作原理如下:http://jsfiddle.net/pangratz666/qySE9/。 – pangratz 2012-05-03 07:14:59