Himmators
Himmators

Reputation: 15006

Add requierd to bind-attr in ember.js?

I try to pass some attributes to an input-field using embers bind-attr.

<input {{bind-attr requierd="field.requierd" type="field.type" name="field.key" id="field.name"}} />

All but requierd work. I assume ember has some sort of list of allowed attributes. Is it possible to add new ones?

Someone had a similair problem and used, though TextField, doesn't seem to be the thing I should extend.

App.TextField = Ember.TextField.extend({
    attributeBindings:  ['required'],
    required:           null
});

Upvotes: 0

Views: 155

Answers (1)

selvagsz
selvagsz

Reputation: 3872

You got the right train dude. Reference DOCS here. Things went wrong because of using bare input tags. Use the extended text-field component or more cleaner way is to register it as a helper and use it in hbs

App.TextField = Em.TextField.extend({
  attributeBindings: ['required']
});

Em.Handlebars.helper('input',App.TextField);

Updated

Demo Working

Upvotes: 1

Related Questions