lundi 5 janvier 2015

Can't get static property to work in emberjs class using property bindings

I am trying to create a static property in an ember object (all instances should share the same property and react when it changes). In my case I have 4 different instances, if any of these instances changes the refresh property I want all 4 instances to react to it.


I have found that the refresh binding only executes for the current instance whereby I want it to execute for all instance given it is a static property.



enabled : function() {
...
}.property('refresh'),


selectionChanged : function() {
...
this.incrementProperty('refresh');
}.observes('selection')


I have tried creating the the refresh property using a mixin



var AbstractControlMixin = Ember.Mixin.create({
refresh : 0
});

var AbstractControl = Ember.Object.extend(AbstractControlMixin,{
...
});


an using the reopen technique



var AbstractControl = Ember.Object.extend({
...
});

AbstractControl.reopen({
refresh : 0
});


but neither is working.





Aucun commentaire:

Enregistrer un commentaire