简体   繁体   English

在状态为“ root.loaded.saved”时尝试处理事件“ becameInvalid”

[英]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.

相关问题 在状态root.loaded.updated.inFlight中尝试处理事件`willCommit` - Attempted to handle event `willCommit` on while in state root.loaded.updated.inFlight “尝试处理事件`reloadRecord` <App.User:ember820:me> 处于root.deleted.saved状态时。 ” - “Attempted to handle event `reloadRecord` on <App.User:ember820:me> while in state root.deleted.saved. ” Ember JS,在状态为root.loaded.updated.uncommitted的Transformer handeling事件`didCommit`中解析数据时出错。“ - Ember JS, Error while parsing Data in Transformer handeling event `didCommit` in state root.loaded.updated.uncommitted." 错误:删除记录模型余烬时尝试处理事件`didSetProperty` - Error: Attempted to handle event `didSetProperty` when Deleting record model ember 样式加载事件后的 LitElement 阴影根 - LitElement shadow root after styles loaded event 在事件监听器中反应挂钩保存状态错误? - React hook saved state in Event Listener wrong? JStree:如何将AJAX加载的根节点的状态设置为不确定 - JStree: How to set state of AJAX-loaded root nodes to undetermined 如何从延迟加载的模块访问根状态? - How can I access root state from lazy loaded modules? 在 SvelteKit 中,如果未保存用户状态,是否有办法取消 popstate 事件? - In SvelteKit, is there a way to cancel a popstate event if user state isn't saved? 在执行之前处理外部javascript脚本加载事件 - handle external javascript script loaded event before it's executed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM