I have the following model:
export default DS.Model.extend({
visibility: DS.attr('string'),
visible: Ember.computed('visibility', function() {
get() {
return this.get('visibility') === 'visible';
},
set(key, value) {
if(value) {
this.set('visibility', 'visible');
} else {
this.set('visibility', 'hidden');
}
}
});
Then, in a template, I have a checkbox bound to the visible
computed property:
{{input type="checkbox" checked=model.visible}}
It all works great, except when I save the model. After saving the model, model.get('visible')
returns null. I'm not sure what's happening, but it seems the model is not consulting my computed property, as it can only possibly return true or false.
I am using Ember Data with the ActiveModelSerializer. Ember v1.13.3.
Aucun commentaire:
Enregistrer un commentaire