Reputation: 852
I have this, what should be simple, problem in Ember.js. Based on a boolean property, I want to choose whether or not to set a data attribute. This works perfect for class attributes and I can set the data attribute with a property (so in this example {{bind-attr data-toggle="label"}} works).
<a href="#" {{bind-attr class="hasContent:dropdown-toggle"}} {{bind-attr data-toggle="hasContent:dropdown"}}>
{{label}}
{{#if hasContent}}<b class="caret"></b>{{/if}}
</a>
What's the fastest/cleanest solution for this? The object in my template is just a Ember.object. I'm using Ember 1.5 & Handlebars : 1.2.1
Upvotes: 1
Views: 2521
Reputation: 1178
Why don't you do it like this
{{#if hasContent}}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{label}}<b class="caret"></b>
</a>
{{else}}
<a href="#">{{label}}</a>
{{/if}}
Upvotes: 1