Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding / removing a class from an ember input

Using ember 1.0 and handlebars 1.0

I want to present an ember input as disabled until the user presses the edit button. I have managed to get the functionality working at the expense of code duplication.

{{#if isEditing}}
  {{input type="text" value=firstName class="form-control" placeholder="First name" }}
{{else}}
  {{input type="text" value=firstName class="form-control" placeholder="First name" disabled=""}}
{{/if}}

just wondering if there was a better way ..

thanks

like image 288
jmls Avatar asked Aug 15 '26 17:08

jmls


1 Answers

Instead of disabled your input with classes, just add the disabled attribute for your input field

{{input type="text" value=firstName class="input-medium" disabledBinding="disabled"}}

Demo Fiddle

like image 137
selvagsz Avatar answered Aug 20 '26 11:08

selvagsz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!