Skip to content

Instantly share code, notes, and snippets.

@etozzato
Last active August 29, 2015 14:01
Show Gist options
  • Save etozzato/9df11535a0e9fad01da8 to your computer and use it in GitHub Desktop.
Save etozzato/9df11535a0e9fad01da8 to your computer and use it in GitHub Desktop.
// I want to nullify segment_id for the model before saving if it was not changed;
// is it okay to mess with _dirtyAttributes ?
actions: {
updateParticipant: function() {
if (!this.get('model._dirtyAttributes').contains('segment_id')) {
this.get('model').set('segment_id', null);
}
return this.get('model').save().then(function() {
return console.log("NOTIFY THE USER!");
});
}
}
@etozzato
Copy link
Author

etozzato commented May 8, 2014

this works but I don't like it...

this.get('model').set('segment_id', false);

@rwjblue
Copy link

rwjblue commented May 9, 2014

Assuming Ember Data, then you can use model.changedAttributes().

See http://emberjs.com/guides/models/working-with-records/#toc_modifying-attributes for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment