You want to do something when your record got saved/validations failed.
Usage
user.observeSaveOnce(success: function(){ // go to next page }, error: function(){ // show validation errors })
Code
# your model.js observeSaveOnce: function(options) { function callback() { var outcome = 'success'; if (this.get('isDirty')) { if (this.get('isValid')) return; // not submitted yet outcome = 'error'; } (options[outcome] || Ember.K).call(this); this.removeObserver('isDirty', callback); this.removeObserver('isValid', callback); } this.addObserver('isDirty', callback); this.addObserver('isValid', callback); }
Hey, great but how would you then proceed to do client side (hook form to a DS.Model) validation?
Sorry, no idea, never needed it 🙂
Hmm, how about, how do you handle client side validation of your records … a gist would be appreciated?
Sorry, lost the code when I switched projects, I think we read the response and showed the text, not sure…
Hmm, thanks … anyway, I get that validation is being worked on in the release. Can’t wait.