1

I'm trying to set the class of my itemViewClass view based on an attribute of the value's content.

The code below produces:

<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>

class is set to 'spanValue' instead of the value from the content.

Any ideas?

thanks.

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>')
})

}),

4

1 回答 1

3

这里有几件事。

首先return this.get('content').span应该可能使用return this.getPath('content.span')或类似的。

但是,您的主要问题在于您应该使用classNameBindings,而不是classNames在定义 itemViewClass 时。

希望有帮助

于 2012-05-01T07:32:15.533 回答