lundi 29 décembre 2014

Attempted to handle event `becameInvalid` while in state 'root.loaded.saved'

I've implemented DS.Errors for my RestAdapter, thanks to Alex Spellers tutorial on server side validation.


However, in this part of my app I want to do a simple client side check to see if the form is complete. (Why not have DS.Errors handle all the errors?)



process: function(upload) {
var form = upload.get('form');

if (!isComplete(form)) {
upload.get('errors').add('field', 'field isempty');
return;
}
// else "Processing..."


The logic here is somewhat simplified, but errors.add() should invalidate, and add an error to the model. However I'm getting the following error:



Uncaught Error: Attempted to handle event `becameInvalid` on <@model:upload:54a1f298ef912a2ace760b0f> while in state root.loaded.saved.


I have read about the state manager, but am unsure as to how, and what state I should transition to before adding an error to my model.


Thanks in advance!



Ember : 1.8.1
Ember Data : 1.0.0-beta.11
Handlebars : 1.3.0
jQuery : 1.11.2




1 commentaire: