我正在使用带有导轨的 ember-data 0.13。我有一个基本信息控制器来处理基本信息模型更新。更新动作是:
update: ->
@content.save()
@content.on('becameInvalid', (response) ->
alert Em.inspect(response.errors)
)
基本信息.hbs:
<aside class='basicinfo-aside'>
{{#if inEditModel}}
<div class='control-group'>
<label for='basicinfo_about_me'>{{t '.basicinfo.edit.about_me'}}</label>
<div class='controls'>
{{view Em.TextArea id='basicinfo_about_me'
class='basicinfo-about-me'
name='basicinfo[about_me]'
valueBinding='aboutMe'}}
</div>
</div>
<div class='action-group'>
<span {{bindAttr class=':about-me-length-remain
hasAboutMeLengthRemain:muted:text-error'}}>
{{aboutMeLengthRemain}}
</span>
<button class='btn-cancel btn' {{action cancel}}>
{{t '.basicinfo.edit.cancel'}}
</button>
<button class='btn-update btn btn-primary' {{action update}}>
{{t '.basicinfo.edit.update'}}
</button>
</div>
{{/if}}
</aside>
<div class='basicinfo-inner'>
{{#unless inEditModel}}
<h5>
{{t '.basicinfo.about_me'}}
{{#if canManage}}
<a class='lnk-edit' href='#' {{action edit}}>
<i class='icon-edit'></i>
</a>
{{/if}}
</h5>
<p class='about-me'>{{aboutMe}}</p>
{{/unless}}
</div>
当我第一次单击带有无效数据的更新按钮时,错误会正确显示,但如果我不修复错误并再次按下更新按钮,Ember 会显示:“未捕获的错误:尝试willCommit
在 rootState.loaded.updated.invalid 状态下处理事件。调用带有未定义的“如何解决谢谢!