Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

Validate an input value is a minimum from a computed

$
0
0

@JordanRDesigns wrote:

I have an item controller that sets a computed that is equal to a current bid amount, plus a minimum increment. This value should be what the user must enter as a minimum value to place a new bid on an item.

So say an item has a current high bid of $100, and the item has a minimum bid increment value of 10, currently on the controller I have a computed that looks like this..

min_bid_amt: Ember.computed('model.item_high_bid','model.item_bid_increment',function(){
  	return this.get('model.item_high_bid') + this.get('model.item_bid_increment');
  }),

In an input on the item.hbs page I have the value mapped to this computed

{{input class="bid-amt" value=min_bid_amt}}`

When the user submits I'm calling an ajax function to place a new bid. There are two things I need to figure out how to make happen (preferably the ember way).

  1. I need the new bid input to have a validation of some sort on it that prevents the user from placing a bid lower than the required new minimum amount, ei. in the example above I don't want them to change the value that was placed to something like $105 when the minimum is $110
  2. I need to prevent the form from submitting if the user has entered a value that is less than the required minimum amount to bid

I don't know if I can use something like ember-validations here (I'm struggling through their documentation to find a way I might be able to do it) or if I should be able to roll my own solution to make this work.

Hope all this makes sense.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles