Ember.js - numeric field support

Does ember provide a numeric field?

I tried using the helper {{input}}, but it doesn't seem to accept the html attributes that apply to numeric fields.

Suppose I have a property valuein my controller, and this is my template:

{{input type="number" min="1" max="10" step="1" value=value}}

min, maxand are stepignored.

I also tried:

<input type="number" min="1" max="10" step="1" {{bind-attr value='value'}}>

Attributes now work, but the binding does not work.

Any thoughts?

+4
source share
1 answer

You need to configure which attributes you want to bind the input field to.

For example:

Ember.TextField.reopen({
  attributeBindings: ['size', 'maxlength', 'minlength', 'min', 'max', 'step']
})

JSFiddle works here: http://jsfiddle.net/bZy6b/

: Binding. Ember , , . , .

1.4 ​​min max: https://github.com/emberjs/ember.js/commit/8eb4e53a478c086d93d2414114e0bd8704237ecc#diff-ef30f4013a02c0c5fceae64680d1899b

1.5.0-beta.1 ( ): https://github.com/emberjs/ember.js/commit/fdfe8495f738c460b0f1595bc8a37a67e568ff0f

+3

All Articles