2016-01-04 41 views
0

使用Polymer for PhoneGap我想添加一个核心列表项目的点击事件来知道列表中的哪个元素被点击。聚合物核心列表项目点击事件

我已经试过:

<core-list id="list" name="list" attributes="" height="120" style="height:100%;" selectionEnabled="true" on-core-select="{{selectedHandler}}"> 
       <template> 
        <core-card id="core_card" layout vertical> 
         <div class="row {{ { selected: selected } | tokenList }}"> 
          <div flex> 
           <core-image style="width:100%; height:200px; border-top-left-radius: 7px; 
            border-top-right-radius: 7px; background-color: lightgray;" src="{{model.event_image}}" sizing="cover" preload> 
           </core-image> 
           </br> 
           <div style="text-transform: none;padding-left:10px;padding-top:10px">{{model.event_title}}</div> 
           <div style="text-transform: none;padding-left:10px;padding-top:10px">{{model.event_location}}</div> 
           </br> 
           <div style="height:1px;width:100%;background:#999"></div> 
           <div style="text-transform: none;padding-left:10px;padding-top:8px;color:#999">READ MORE</div> 
          </div> 
         </div> 
        </core-card> 
        <div style="height:10px"></div> 
       </template> 
       <script> 
        (function() { 
        Polymer({ 
          is: "list", 
          selectedHandler: function(e, detail, sender) { 
           alert('aa'); 
          } 
          }); 
        })(); 
        </script> 
      </core-list> 

但攻从列表中选择项目时不显示的警告对话框。有谁知道我在这里做错了吗?

提前感谢您的时间。

+0

听起来像是重复的http://stackoverflow.com/questions/31888111/tap-listener-for-polymer-iron-list-item –

+0

@GünterZöchbauer我仍然不能使它的工作,该示例不是一个核心列表。 – dorin

+0

对不起,我错过了。你不使用Polymer 1.x?我认为'core- *'与Polymer 1.x不兼容,还是它们? AFAIK铁名单是核心名单的继任者。 –

回答

0

你可以去的一种方法是观察这个。$。list.selection在你的组件中,因为它将被选中的项目更新。