Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js input fields

Tags:

input

ember.js

Is it possible to use standard HTML5 input fields in an Ember.js view, or are you forced to use the limited selection of built in fields like Ember.TextField, Ember.CheckBox, Ember.TextArea, and Ember.select? I can't seem to figure out how to bind the input values to the views without using the built in views like:

Input: {{view Ember.TextField valueBinding="objectValue" }}

Specifically, I'm in need of a numeric field. Any suggestions?

like image 229
reptilicus Avatar asked Nov 28 '22 05:11

reptilicus


1 Answers

EDIT: This is now out of date you can achieve everything above with the following:

{{input value=objectValue type="number" min="2"}}


Outdated answer

You can just specify the type for a TextField

Input: {{view Ember.TextField valueBinding="objectValue" type="number"}}

If you want to access the extra attributes of a number field, you can just subclass Ember.TextField.

App.NumberField = Ember.TextField.extend({
  type: 'number',
  attributeBindings: ['min', 'max', 'step']
})

Input: {{view App.NumberField valueBinding="objectValue" min="1"}}
like image 158
Bradley Priest Avatar answered Dec 09 '22 10:12

Bradley Priest