Javascript 在Emberjs/Handlebar中为html元素定义ID失败

Javascript 在Emberjs/Handlebar中为html元素定义ID失败,javascript,testing,ember.js,handlebars.js,dalekjs,Javascript,Testing,Ember.js,Handlebars.js,Dalekjs,我有以下问题: <ul class="aClass"> {{#if something}} <li>{{#link-to "blub" bind-attr data-testid=aID}}{{loc "blub"}}{{/link-to}}</li> {{/if}} </ul> {{{如果有什么} {{{#链接到“blub”bind attr data testid=aID}{{{loc“blub”}}{{/link to}} {

我有以下问题:

<ul class="aClass">
  {{#if something}}
  <li>{{#link-to "blub" bind-attr data-testid=aID}}{{loc "blub"}}{{/link-to}}</li>
  {{/if}}
</ul>
    {{{如果有什么}
  • {{{#链接到“blub”bind attr data testid=aID}{{{loc“blub”}}{{/link to}}
  • {{/if}
因此,我希望在结果元素中有一个元素(指向的链接呈现为
),id为aId。但是元素在呈现的HTML中不包含想要的id。大概是这样的:

有什么想法吗?

尝试使用引号:

{{{#链接到“blub”bind attr data testid=“aID”}{{{loc“blub”}}{{/link to}}


缺少引号将导致Ember尝试在当前视图上下文上查找属性,而不是像您希望的那样吐出字符串。

在Ember中,不应在指向帮助的
链接中使用
bind attr
,因为它只应在html元素中使用:

<a {{bind-attr href=myLink}}>My Link</a>
如果缺少引号,则该属性不会呈现到HTML中

但您还需要重新打开
链接视图

Ember.LinkView.reopen({
    attributeBindings: ['data-testID']
});

嘿,你让我开心了:)但我必须加上引号才能让它正常工作-->@Sheldonbbaker也谢谢你:)
Ember.LinkView.reopen({
    attributeBindings: ['data-testID']
});