Reputation: 19114
I have a view with the following:
App.MyView = Ember.View.extend({
isSet: false,
layoutName: 'myview',
click: function() {
this.set('isSet', !this.get('isSet'));
}
};
And the template for it:
<i {{bind-attr class=":fa isSet:fa-check"}}></i> Toggle
The click
event is working fine, and updates isSet
(I can see that in ember inspector), but the bound class does not get added. Is there something wrong in my logic?
Upvotes: 0
Views: 610
Reputation: 634
If you are using above ember 1.11
then use the below tag
Reference :
http://www.hutchinson.io/bind-attr-is-dead/
Upvotes: 0
Reputation: 1202
Another possible solution, not to the OP's problem but to one with a similar title.
When using bind-attr
to bind property changes and element class, it is important to include also static class mapping inside the bind-attr
helper and not in a separate, static, class attribute.
This will not always work:
<div class="round" {{bind-attr class="highlighted:hl"}}>Inner text</div>
The correct way is:
<div {{bind-attr class=":round highlighted:hl"}}>Inner text</div>
Upvotes: 0
Reputation: 993
Use view.isSet
instead of isSet
in your template.
<i {{bind-attr class=":fa view.isSet:fa-check"}}></i> Toggle
Upvotes: 1