私は ember.js を学んでいますが、まだ何も構築していません。
モデル オブジェクトにデータを格納し、ビューとモデルの間の接着剤として機能するコントローラーを使用しています。コントローラーにはモデルのインスタンスに設定されたコンテンツがあり、ビューにはコントローラー内のコンテンツへのバインディング (したがってプロキシによるモデルへのバインディング) があります。そのようです:
// js
App.MyModel = Ember.Object.extend({foo:''});
App.myController = Ember.Object.create({
content: App.MyModel.create()
});
// html
{{view Ember.TextInput valueBinding="App.myController"}}
ここまでは順調ですね。しかし、このパラダイムをネストされたコレクションに適用する方法がわかりません。
//js
App.ChildController = Ember.ArrayController.extend();
App.NestedModel = Ember.Object.extend({
init: function() {
this._super();
this.set('children', []);
// Here: I can't give a global name for the content binding, and I don't know how to give a relative one
this.set('childController', App.ChildController.create({contentBinding: 'children');
}
});
App.myController = Ember.ArrayController.create({
content:[],
newChild: function() {
this.pushObject(App.NestedModel.create());
}
});
// html
{{#collection contentBinding="App.myController"}}
{{#collection contentBinding="content.childController"}} <!-- nope -->
{{content.childField}}
{{/collection}}
{{/collection}}
これはあなたがいじることができるものです:http://jsfiddle.net/DwheG/
私が求めているのは:
- 私は物事を正しくモデリングしていますか?
- 子コントローラーのコンテンツをバインドするにはどうすればよいですか? 文字列を使用する必要がありますか? オブジェクト (
this
) を渡してもうまくいきませんでした。Ember のパス解決アルゴリズムはどこかに文書化されていますか? - ネストされたコレクション ヘルパーをネストされたコントローラにバインドするにはどうすればよいですか?