【发布时间】:2015-04-26 07:19:20
【问题描述】:
我的表单中有一个金额字段,我在控制器中提交后乘以 100。 问题是视图在进入下一页之前渲染了乘法。 我怎样才能避免这种情况? 更一般地,如何防止视图在提交后显示修改后的值?
我在后端使用带有 rails 的 ember.js,但我认为这更像是一个 MVC 问题。
这是视图:
{{input value=model.amount mask="999[999].99"
classNames="form-control" placeholder=(t 'transactions.amount')}}
这是控制器:
actions: {
create: function() {
var _this = this;
var model = this.get('model');
model.set('amount', model.get('amount') * 100);
model.save().then(function(transaction) {
_this.get('target').transitionToRoute(_this.get('destination'), transaction.get('id'));
}, function(response){
_this.set('errors', response.errors);
});
}
}
【问题讨论】:
-
请提供您的代码
标签: model-view-controller ember.js