![](/img/trans.png)
[英]Attempted to handle event `willCommit` on while in state root.loaded.updated.inFlight
[英]Attempted to handle event `becameInvalid` while in state 'root.loaded.saved'
感謝Alex Spellers關於服務器端驗證的教程,我為RestAdapter實現了DS.Errors 。
但是,在我的應用程序的這一部分中,我想做一個簡單的客戶端檢查,以查看表單是否完整。 (為什么沒有DS.Errors處理所有錯誤?)
process: function(upload) {
var form = upload.get('form');
if (!isComplete(form)) {
upload.get('errors').add('field', 'field isempty');
return;
}
// else "Processing..."
這里的邏輯有些簡化,但是errors.add()應該無效,並向模型添加錯誤。 但是我收到以下錯誤:
Uncaught Error: Attempted to handle event `becameInvalid` on <@model:upload:54a1f298ef912a2ace760b0f> while in state root.loaded.saved.
我已經閱讀了有關狀態管理器的信息,但不確定在向模型中添加錯誤之前應如何以及將狀態轉換為什么狀態。
提前致謝!
Ember : 1.8.1
Ember Data : 1.0.0-beta.11
Handlebars : 1.3.0
jQuery : 1.11.2
再次討論之后,我遇到了以下帖子 。 有什么解決我的問題是不發送willCommit
,但發送upload.send('becomeDirty');
在執行以下操作之前:
upload.get('errors').add('field', 'field isempty');
現在可以添加錯誤,因為上傳模型未處於saved
狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.