Search code examples
cssember.jshandlebars.js

Adding conditional class to EmberJS handlebar element


I'm trying to use a EmberJS handlebar texture element and conditionally add a css class to it. Code looks like this:

{{textarea class={{if isBlue 'blue-css' 'green-css'}} }}

This does not work. The inner handlebars expression is inserted literally into the html, but I can use an html textarea:

<textarea class={{if isBlue 'blue-css' 'green-css'}} ></textarea>
How can I do this using an EmberJS handlebars expression, if at all? Thanks


Solution

  • You can try,

    {{textarea classNameBindings="isBlue:blue-css:green-css"}}
    

    as explained here docs