How to set two class names for Ember.js input helper

I am trying to bind an input element as follows:

{{input value=email type="text" placeholder="Enter email" class=emailError:with-error}} 

it works just fine while I try to assign it only one class name ".with-error". how can i assign 2 class names so that it will be: ".with-error.second-class"? I know how to do this:

 {{bind-attr class=":secondClass emailError:with-error"}} 

but this does not work with input helper.

Thanks!

+8
ember.js-view
source share
1 answer

This function is poorly documented, but when defining attributes in the Handlebars helper, you can either leave quotation marks to indicate that you want the attribute value to be a related variable, or you can add the suffix "Bind", and then use quotation marks with an expression similar to the one you would use with {{bind-attr}} .

So, in your case, the following should work:

 {{input value=email type="text" placeholder="Enter email" classBinding="emailError:with-error :myClassName"}} 

Note that instead of class=myBoundValues we use classBinding="myBoundValue" .

+17
source share

All Articles