0

Ember.js(1.0) で自分自身からビュー クラスとバインド プロパティを作成する方法は? このようなもの:

SomeClass = Ember.View.extend
  someProp: true
  createChildView: ->
   OtherView.create
    somePropBinding: 'this.someProp'
4

1 に答える 1

0

のプロパティparentViewへのアクセスを取得するために使用すると、次のように動作するはずです。parentView

例:

App.MyView = Ember.ContainerView.extend({
  someProp: true,
  didInsertElement: function() {
    var viewClass = App.SomeView.create();
    this.pushObject(viewClass);
  }
});

次にEmber.computed.alias('...)、バインディングを作成するために使用できます。

App.SomeView = Ember.View.extend({
  anotherProp: Ember.computed.alias('parentView.someProp'),
  didInsertElement: function() {
    console.log('anotherProp: '+this.get('anotherProp'));
  }
});

コードをスクリプト化しなくてすみません:)

実施

それが役に立てば幸い。

于 2013-09-16T19:49:52.667 に答える