Ember.js / Handlebars.js binds a conditional property of a class to the {{# link-to}} helper

I am trying to add a class to the link attribute, but the class name is conditional.

{{#link-to "role" this classNames="isLoading:is-loading" tag="tr" }} <td {{ bind-attr class="isLoading:is-loading"}}>{{ name }}</td> <td>{{ role }}: {{ isLoading }}</td> <td>EDIT</td> {{/link-to}} 

So just like that. But for some reason this does not work.

Is there any other way to do this?

+7
source share
1 answer

Just use classBinding instead of classNames :

 {{#link-to "role" this classBinding="isLoading:is-loading" tag="tr" }} <td {{ bind-attr class="isLoading:is-loading"}}>{{ name }}</td> <td>{{ role }}: {{ isLoading }}</td> <td>EDIT</td> {{/link-to}} 
+12
source share

All Articles