0

我主要为我的英语感到抱歉。Backbone js 每个列表我想选择并在循环中只显示一个值。我怎样才能做到这一点 ?我将向您展示示例代码。如果有不明白的地方,请询问。

在此先感谢您的帮助。

主干JS代码;

    _template: '<div class="list-container">{{{list}}}</div>',


    defaultListLayout: {
        rows: [
            [
                {
                    name: 'entityType'
                },
                {
                    name: 'calculationType'
                },
                {
                    name: 'calculationValue'
                },
                {
                    name: 'queryType'
                }
            ]
        ]
    },

    afterRender: function () {
        this.collection = new MultiCollection();
        this.collection.seeds = this.seeds;
        this.collection.url = 'CareerSteps/action/careerGoal';
        this.collection.maxSize =         this.getConfig().get('recordsPerPageSmall') || 5;
        this.collection.data.entityTypeList = this.scopeList;            
        this.listenToOnce(this.collection, 'sync', function () {
            this.createView('list',         'career:views/dashlets/templates/newtemplate', {
                el: this.options.el + ' > .list-container',
                pagination: false,
                type: 'list',                    
                checkboxes: false,
                collection: this.collection,
                listLayout: this.listLayout,
            }, function (view) {
                view.render();
            });
        }, this);

        this.collection.fetch();
    },

HTML 代码;

<ul class="list-group">          
    {{#each rowList}}
        <li data-id="{{./this}}" class="list-group-item list-row">        
          {{{var this ../this}}} <br>        
        </li>
    {{/each}}
</ul>
4

0 回答 0