2012-04-30 6 views
1

値のコンテンツの属性に基づいてitemViewClassビューのクラスを設定しようとしています。アイテムの値に基づいてCollectionViewアイテムのクラスを設定する

以下のコードは、生成:

<span id="ember326" class="ember-view spanValue"> 
<h5> 
<script id="metamorph-32-start" type="text/x-placeholder"> 
Select 
<script id="metamorph-32-end" type="text/x-placeholder"> 
</h5> 
</span> 

クラス「spanValue」の代わりにコンテンツの値に設定されています。

アイデア?

ありがとうございました。

listHeaderView: Ember.CollectionView.create({ 
classNames: ['jobs-list-header', 'row'], 
content: [ 
    Ember.Object.create({ 
     span: 'span1', 
     label: 'Select' 
    }), 
    Ember.Object.create({ 
     span: 'span1', 
     label: 'Status' 
    }), 
    Ember.Object.create({ 
     span: 'span1', 
     label: 'Tax Year' 
    }), 
    Ember.Object.create({ 
     span: 'span3', 
     label: 'Municipality' 
    }), 
    Ember.Object.create({ 
     span: 'span3', 
     label: 'School District' 
    }), 
    Ember.Object.create({ 
     span: 'span1', 
     label: 'Received' 
    }) 
], 
itemViewClass: Ember.View.extend({ 
    tagName: 'span', 
    classNames: ['spanValue'], 
    spanValue: function() { 
     return this.get('content').span 
    }.property(), 
    template: Ember.Handlebars.compile('<h5>{{content.label}}</h5>') 
}) 

})、

答えて

3

物事のカップルがここにあります。

最初にreturn this.get('content').spanにはreturn this.getPath('content.span')などが使用されています。

ただし、あなたの主な問題は、classNameBindingsを使用する必要があり、itemViewClassを定義するときにはclassNamesではないということにあります。

希望があれば

+0

ありがとうございました。 – dgaj

+1

classNameBindingsもディープパスを使用できます。そのため、ローカルプロパティを作成する必要はなく、 'content.span'にバインドできます。 –