【发布时间】:2013-07-02 19:38:22
【问题描述】:
我在使用 Ember 和 Ember Data 处理服务器端验证时遇到问题。
发生验证错误时,API 返回代码 422。Ember 数据然后触发模型上的 becameInvalid 回调。
从这里开始,我不确定处理我遇到的错误的最佳方法是什么,以及如何让它们冒泡到视图中。
App.Challenge = DS.Model.extend Ember.Validations,
title: attr('string')
summary: attr('string')
# other attributes
becameInvalid: (errors) ->
# is it the place where I should handle the errors?
# how would I make the errors bubble up to the view here?
我有 2 个问题。
- 我不确定
becameInvalid是否是处理错误的地方,如果是,如何使错误显示在视图中 - 在
becameInvalid中,@get('isValid')返回true,这对我来说没有意义。
【问题讨论】:
标签: validation ember.js server-side ember-data