Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js/Handlebars.js bind conditional class property to {{#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 this. But somehow it doesn't work.

Is there another way to do this?

like image 490
Jay Claiton Avatar asked Jan 13 '14 15:01

Jay Claiton


1 Answers

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}}
like image 120
dcodesmith Avatar answered Sep 23 '22 07:09

dcodesmith