0

You can bind the class "active" to an element like this

<button {{bind-attr class="isActive:active"}}>Test</button>

Even static classes are possible:

<button {{bind-attr class=":btn isActive:active"}}>Test</button>

But how to get a button like this

<button {{bind-attr class=":btn :facet%id%"}}>Test</button>

to have the value of "id" bound to the static-value?

<button class="btn facet384"></button>
4

1 回答 1

1

你可以试试帮手

Ember.Handlebars.helper("btn-facet", function(a,hash){
    return new Handlebars.SafeString('class="btn facet'+a+'"');
});

你将不得不在模板上使用 unbound 我不知道如何创建一个返回未绑定值的助手,这是它工作的 jsbin,而不是最好的方式http://jsbin.com/UqERudud/1/edit

于 2014-02-03T14:28:50.360 回答