With emberjs, how to extend attributeBindings parameters from parent view?

I am trying to have some inheritance with the Bindings attribute between two views.

(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() {

      

I tried this.get ('attributeBindings'). concat (['data-position']) and Ember.MobileBaseView.get ('attributeBindings'). concat (['data-position']) and Ember. MobileBaseView.attributeBindings.concat (['position data'])

Maybe I just need to do the Bindings: ['data-role', 'data-theme', 'data-position'] attribute, but I would rather find a better solution.

+3


source to share


1 answer


Ember.View#attributeBindings

is a concatenated property , which means that if you overwrite it in a subclass, the values ​​from the superclass are concatenated. So this works, see 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']
});​

      

+7


source







All Articles