铁列表多选项会多次添加项目以供选择

时间:2017-08-07 21:52:44

标签: javascript polymer

我有一个multi-selection已启用iron-list,我的问题是点击后点击的[[children]]元素会添加到{{selectedChildren}},而不是选择/取消选择项目。 ,每次点击一次。

<iron-list items="[[children]]" selected-items="{{selectedChildren}}" selection-enabled multi-selection>
    <template>
        <div class$="[[iconForItem(selected, item)]]">
            <iron-image class="avatar" sizing="contain" src="[[item.pic]]"></iron-image>
            <div class="pad">
                <div class="primary" th:inline="none">[[item.name]]</div>
                <div class="secondary dim" th:inline="none">[[item.bdate]]</div>
                <div><paper-textarea value="{{item.comment}}" on-tap="noFoc"></paper-textarea></div>
            </div>
        </div>
    </template>
</iron-list>

这可能是什么问题?

1 个答案:

答案 0 :(得分:1)

问题是:

properties: {
    selectedChildren: {
        type: Array, // bad idea
        value: []    // bad idea
    }
}

应该是:

properties: {
    selectedChildren: {
        type: Object // This works
    }
}