我在聚合物应用程序中选择 ds 列表时遇到问题。我有一个有效的聊天标题列表(实现为深度流记录),应该用于选择匹配的聊天历史记录(实现为包含聊天消息作为记录的深度流列表)。
<div class="chatlist">
<!-- This is the list of chats -->
<paper-menu selected="[[chatlist]]">
<paper-item>
<paper-input label="New Chat:" id="chatName" on-keydown="setChatName"></paper-input>
</paper-item>
<template
is="dom-repeat"
items="[[todos]]"
as="recordId">
<div role="listbox">
<chat-names
name="[[recordId]]">
</chat-names>
</div>
</template>
</paper-menu>
</div>
<!-- this is the chat history -->
<iron-pages
selected="[[chatlist]]"
attr-for-selected="chatView"
fallback-selection="chatView404"
role="main">
<template
is="dom-repeat"
items="[[todos]]"
as="recordId">
<chat-view
chatView="[[???]]"
name="[[recordId]]">
</chat-view>
</template>
</iron-pages>
所以这是我的问题:虽然聊天列表工作正常,但我不知道如何将聊天本身的选择连接到匹配聊天历史的显示。
聊天标题的创建发生在 paper-inputon-keydown="setChatName"
函数中,如下所示:
setChatName: function (e) {
if (e.which === 13) {
var recordId = 'polymer-example/' + this.ds.getUid();
var todo = this.$$( '.new-record-input' ).value;
var todoRecord = this.ds.record.getRecord( recordId );
var todoList = this.ds.record.getList( this.name );
todoRecord.set( { name: todo, checked: false } )
todoRecord.whenReady( function() {
todoList.addEntry( recordId );
} );
this.$.chatName.value = '';
}
},
我现在如何不仅可以设置聊天名称本身的记录,还可以设置包含聊天记录的 ds-list?并且: ds-list 的哪些属性有用(例如,id?名称?)用作选择它的属性?
对不起,很长的问题,每一个答案都非常感谢!