I have a form where users can change their profiles. For example, user name. It’s bound on an object with extraction of some properties from user model. So if I have user name in header, it doesn’t get changed as user types. But how to deal with saving process? Changes will be reflected immediately if I do model.setProperties(form_model)
and I’d like to be sure that changes were actually persisted (no validation errors, etc). How to properly deal with this case?
So I ended up making a mixin that provides clean
property on model that contains persisted attributes, not sure if all possible events handled though. Is there standard way to access only clean versions of attributes?
CleanAttributes = Ember.Mixin.create
_updateCleanAttributes: ->
@eachAttribute (attr, meta) => @get('clean').set(attr, @get(attr))
_createClean: Ember.on 'init', ->
@set 'clean', Ember.Object.create()
_populateClean: Ember.on 'didLoad', -> @_updateCleanAttributes()
_updateClean: Ember.on 'didUpdate', -> @_updateCleanAttributes()