2012-03-28 1 views
3

2つのView間でattributeBindingsを使用して継承を試行しています。私は( 'attributeBindings')this.getを試してみるemberjsでは、親ビューからattributeBindingsパラメータを拡張する方法は?

(function(exports) { 
Ember.MobileBaseView = Ember.View.extend({ 
    attributeBindings:['data-role', 'data-theme'], 
    'data-theme': 'a' 
}); 
})({}); 


(function(exports) { 
Ember.ToolbarBaseView = Ember.MobileBaseView.extend({ 
    attributeBindings:this.get('attributeBindings').concat(['data-position']), 
    'data-position': function() { 

。連結([ 'データ位置'])Ember.MobileBaseView.get( 'attributeBindings')。([ 'DATA-連結位置 '])Ember.MobileBaseView.attributeBindings.concat([' データ位置 '])

はおそらく、私はちょうどattributeBindingsを実行する必要があります。[' データ-役割」、 'データ・テーマ'、 'data-position']、ですが、私はむしろより良い解決策を見つけるでしょう。

答えて

7

Ember.View#attributeBindingsは、concatenated propertyです。つまり、サブクラスで上書きすると、スーパークラスの値が連結されます。だから、作品これは、http://jsfiddle.net/pangratz666/r72dz/を参照してください。

Ember.MobileBaseView = Ember.View.extend({ 
    attributeBindings: ['data-role', 'data-theme'], 
    'data-theme': 'a' 
}); 


Ember.ToolbarBaseView = Ember.MobileBaseView.extend({ 
    attributeBindings: ['data-position'] 
});​ 
+0

おかげで多くのことを、私は私のためのコードでのエラーのため、このように働いていないthinkingsました。私は今日新しいことを学ぶ:)。 – tolbard

+0

うれしい私は助けることができました! – pangratz

関連する問題