2014-02-07 96 views
1

我像往常一樣使用link-to幫手來提供一些圍繞我的應用程序的移動。我正在嘗試使用classBinding屬性將CSS類hide分配給鏈接。這不起作用,我不確定這是因爲我誤解了上下文還是什麼,真的。Emberjs classBinding無法在鏈接上工作

這裏是模板的鏈接的相關部分:

{{#each SimpleSearchOptions}} 
    {{#if isResultsView}} 
     {{#link-to 'simpleSearchResults' tagName='li' classNames='chosentab' href=false}} 
      <a><span>{{qname}}</span><i class="icon-info-circled helpiconleft"></i></a> 
     {{/link-to}} 
    {{else}} 
    {{#link-to 'simpleSearchOption' this tagName='li' classNames='chosentab' classBinding='hidden:hide' href=false}} 
     <a><span>{{qname}}</span><i class="icon-info-circled helpiconleft"></i></a> 
    {{/link-to}} 
    {{/if}} 
{{/each}} 

在這裏的是,它是基於關閉的模型的一部分:

App.SimpleSearchOptions = [ 
    { 
     "id" : 0, 
     "qname": "Application", 
     "description": "When you open a door you need one of these applications.", 
     "answers": [ 
      { 
       "value" : "*", 
       "title": "Any/Unknown", 
       "description": "Unknown or variable Applications.", 
       "qname": "Application" 
      }, 
      { 
       "value" : 1, 
       "title": "Building Temperature Control", 
       "description": "Prevents warm air from leaving a heated building or cool air from leaving an air-conditioned one.", 
       "qname": "Application" 
      }, 
     ..... 
     ] 
    }, 
    { 
     "id" : 7, 
     "qname": "Heating Power", 
     "description": "If a unit is heated using electricity, different amounts of power (in kW) are available.", 
     "hidden": true, 
     "answers": [ 
      { 
       "value" : "*", 
       "title": "Any/Unknown", 
       "description": "", 
       "qname": "Heating Power" 
      }, 
      { 
       "value" : "B", 
       "title": "6", 
       "description": "", 
       "qname": "Heating Power" 
      }, 
      { 
       "value" : "C", 
       "title": "6.1", 
       "description": "", 
       "qname": "Heating Power" 
      }, 
      ...... 

首先{{#if ResultsView}}作品只是找到當我稍後動態地將一個元素添加到SimpleSearchOptions陣列。爲什麼classBinding='hidden:hide'無法正常工作?

感謝您的幫助。

回答

0

您應該使用classNameBindings

{{link-to 'Click to see the pretty colors!' 'colors' classNameBindings="isGreen:green"}} 

Simple isGreen Example

+0

對不起回覆的很長一段時間 - 我試圖將其更改爲classNameBindings和它不工作,要麼。 –