我有一个使用iron-list来显示对象数组的自定义元素。每个项目通过模板生成,如下所示:
<iron-list id="projectList" items="[[projects]]" indexAs="_id" as="projLI" class="layout flex">
    <template>
        <div>
           <paper-material id="itemShadow" animated elevation="1">
               <div class="item layout horizontal" onmouseover="hoverOver(this)" onmouseout="hoverOut(this)">
                   <!-- I use a paper-menu-button to display a list of available actions here -->
                   <!-- list item object content here such as: [[projLI.desc]] etc. -->
               </div>
           </paper-material>
        </div>
    </template>
</iron-list>什么是最好的聚合物友好型方法来检测铁列表项目本身的两个抽头事件(理想情况下知道哪些项目是通过projLI._id实际点击的),同时也能够以不同的方式处理内部的paper-menu-button抽头事件?
我已经注意到Polymer1.0的新事件侦听器(https://www.polymer-project.org/1.0/docs/devguide/events.html),作为一种可能的方法,它试图侦听不同的元素点击事件(如页面中的示例1所示),但我不确定这在这里是否有效。我还考虑过在铁列表中使用iron-selector吗?这可行吗?考虑到铁选择器只有一个子元素(即铁列表元素,而不是模板化的子元素),我也不确定它是否会起作用。
我觉得我错过了一种很简单的方法来完成这件事。谁能给我看看灯吗?
发布于 2015-08-11 17:53:05
https://stackoverflow.com/questions/31888111
复制相似问题