我嘗試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