jeudi 27 octobre 2016

Ember overwritten model property not being serialised

I'm using Ember 2.4.2

app/models/product.js
export default DS.Model({
    type: attr('string'),
    color: attr('string')
});

app/models/blue-bags.js
export default Product.extend({
    type: Ember.computed('color', function() {
        if (this.get('color') === 'blue') {
            return 'bag';
        }
        return '';
    })
});

The form that these properties are used in do show that type is set to 'bag' when the color is blue, but sending this data to the server doesn't (yes color was blue when sending data to the server).

Is this the correct way to overwrite properties of a model?




Aucun commentaire:

Enregistrer un commentaire