I’m wondering if theres a build in way to ‘automatically’ save a model when one of its attributes has changed? I tried something to implement in a controller like this:
//base controller
export default Ember.ObjectController.extend(TStringGet, {
modelChange: function () {
console.log('model changed: ', this.get('model'));
// model.save() will be called here
},
watchModel: function () {
var _this = this;
this.get('model').eachAttribute(function (name, meta) {
_this.addObserver(name, _this.modelChange);
});
this.get('model').eachRelationship(function (name, meta) {
//
});
}.observes('model')
It seems to work for standard atributes but for a belongsTo relation attribute I’m not sure how to handle this (have a related model selectable in a dropdown and when changing it nothing happens… ) . In general, I’m not really sure if this is the most standard way to do this ember…