I've been trying to store a list of changes to a model into another model before saving it, so that I can recall the changes to undo previous changes. This is the code that I'm using:
var changes = item.changedAttributes();
var newUndo = this.store.createRecord('undo', {
item_id: item.get('id'),
changes: changes
});
And my checkbox is a typical one:
{{input type="checkbox" checked=checked class="checkbox"}}
I have a component for the checkbox that sends a save action when checked changes, and the controller's save method is calling the code above when before saving the record:
import Ember from 'ember';
export default Ember.Component.extend({
checked: false,
model: null,
watchChecked: function () {
this.sendAction('save', this.get('model'))
}.observes('checked')
});
This works well for string attributes, but with boolean checkboxes, it's not acting as expected. This is what I'm seeing:
Page load, unchecked item is checked:
changes: {}
Then unchecked:
changes: {print_copy_sent: true,true}
Then checked again:
changes: {print_copy_sent: false,false}
Aucun commentaire:
Enregistrer un commentaire