[英]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 . 感谢Alex Spellers关于服务器端验证的教程,我为RestAdapter实现了DS.Errors 。
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?)
(为什么没有DS.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. 这里的逻辑有些简化,但是errors.add()应该无效,并向模型添加错误。 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
After revisiting this I came across the following post . 再次讨论之后,我遇到了以下帖子 。 What solved my problem was not sending
willCommit
, but sending upload.send('becomeDirty');
有什么解决我的问题是不发送
willCommit
,但发送upload.send('becomeDirty');
before executing the following: 在执行以下操作之前:
upload.get('errors').add('field', 'field isempty');
Now errors can be added as the upload model is not in the saved
state. 现在可以添加错误,因为上传模型未处于
saved
状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.