使用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>但当轻触列表中的项目时,不会显示警告对话框。有人知道我哪里做错了吗?
提前感谢您的宝贵时间。
发布于 2016-01-05 03:50:47
您可以使用的一种方法是观察组件中的this.$.list.selection,因为它将使用所选的项进行更新。
https://stackoverflow.com/questions/34587724
复制相似问题