samedi 16 juillet 2016

Ember oneWay Binding not working as expected

I have a controller, that serves a default- production of a model to a template

activeProduction: Ember.computed('model.productions', function() {
    // as default serve first Production
    return this.get('model.productions').get('firstObject');
}),

In this production-model i have a property 'settings' that I want to be modified temporarily, without affecting the actual value in the store, so I made a computed oneWay property for those settings:

productionSettingsComputed: Ember.computed.oneWay('activeProduction.settings'),

Those settings are accessed and changed in a template like this:

saved Settings:<br>
<br>
computed oneWay Settings:<br>
<br>



(the form/checkbox is just a custom component wrapping a default ember-form-checkbox)

I now expected that if I change the value in the checkbox, that only the second value () changes. But also the 'stored' value in is changing.
So that 'oneWay' isn't realy only oneWay.

Am I misunderstanding something, or did I make a mistake somewhere?

Yes, I know, that I could do a work around with discarding changes later, but this would give me headaches about user-rights and other stuff...

(Emberjs 2.5)




Aucun commentaire:

Enregistrer un commentaire