Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the size attribute of an Ember.TextField

Tags:

ember.js

I have the following element in an Ember view:

{{view Ember.TextField size="30" valueBinding="urlSearch.search_url"}}

But when I inspect the rendered element, the size attribute is not in the element:

<input id="ember346" class="ember-view ember-text-field" type="text" value="http://www.bdec-online.com/bd-cmpy/bd-cz.cfm">

Can anyone tell me how can I set the size attribute of an Ember.TextField?

like image 413
dagda1 Avatar asked Feb 28 '12 15:02

dagda1


2 Answers

I've just submitted a pull request to add size and maxlength to Ember.TextSupport:

https://github.com/emberjs/ember.js/pull/545

While you're waiting for that, you could patch Ember.TextField like this:

Ember.TextField.reopen({
  attributeBindings: ['size', 'maxlength']
});
like image 149
Dan Gebhardt Avatar answered Sep 22 '22 12:09

Dan Gebhardt


More info:

  {{view Em.TextField attributeBindings="size" size="10"}}

Or:

App.MyTextField = Em.TextField.extend({
  attributeBindings: ['size'],
  size: 2
});

{{view App.MyTextField}}

Em.TextField defines size as a binding but it appears you have to redefine it in your subclass... but I'm I noob at Ember so what do I know.

like image 25
sshaw Avatar answered Sep 22 '22 12:09

sshaw