Ember.CollectionViewの仕組みを理解しようとしていますが、 ArrayControllerのコンテンツをDOM に表示する際に基本的な問題が発生しています。ここに私の小さなjsfiddle実験がありますので、自分の目で確かめてください。コーヒースクリプトは次のとおりです。
window.App = Ember.Application.create()
window.App.initialize()
App.Item = Em.View.create
tagName:'li'
willInsertElement: () ->
console.log "I **WILL** indert the element", this.$()
didInsertElement: () ->
console.log "I **DID** insert the element", this.$()
template: Ember.Handlebars.compile("~~ {{view.content.title}} ~~")
App.items = Em.ArrayController.create()
App.items.set('content',[
Em.Object.create({title:"AN"}),
Em.Object.create({title:"Epic"}),
Em.Object.create({title:"View"})
])
App.epicView = Ember.CollectionView.create
classNames: ['epic-view']
contentBinding: 'App.items'
itemViewClass: 'App.Item'
App.epicView.appendTo('body')
そのフィドルの出力でわかるように、リスト内のオブジェクトのタイトルにアクセスして表示する方法を理解できませんでした。への呼び出しを使用してボディにビューを追加するとApp.epicView.appendTo('body')
、3 つのオブジェクトを反復しているように見えますが、何も出力されません。
ここで何が欠けているのですか?
ps: 私はEmber 1.0preを使用しています