ember.js - MVC controller changes input field after submission -


i have amount field in form multiply 100 after submission in controller. problem view renders multiplication before moving on next page. how can avoid that? more generally, how prevent view display modified value once it's submitted?

i'm using ember.js rails in backend, think it's more of mvc problem.

this view:

{{input value=model.amount mask="999[999].99"         classnames="form-control" placeholder=(t 'transactions.amount')}} 

and controller:

  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);   }); } 

}

this case use computed property, use in template:

displayamount: function(key, value, previousvalue) {     // setter     if (arguments.length > 1) {       this.set('amount', value * 100);     }      // getter     return this.get('amount') / 100;   }.property('amount') 

the syntax computed properties going change may need version:

displayamount: ember.computed("amount", {   get: function() {     return this.get("amount") / 100;   },   set: function(key, amount) {    this.set("amount", amount * 100);   } }) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -