本文介绍了sencha触摸列表tpl事件参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的列表视图中,我在 initialize
事件
In my list view, I put addEventListener
( alias on
) in my initialize
event
initialize: function (component) {
component.element.on({
tap: {
scope: this,
fn: 'onTap',
delegate: 'div.side-itemDelete'
}
});
},
但是,如果还有更多 delegate
(具有id或class的其他元素),我需要绑定一个事件,该如何处理呢?
这是我的XTemplate:
But if there are more delegate
( other element with id or class) I need to bind an event, how can I handle it?
This is my XTemplate:
new Ext.XTemplate(
'<div class="side-weatherListItem no-dragging">',
'<div class="side-itemLocation">',
'<div>{[values.city.toUpperCase()]}</div>',
'<div>{[values.text.toUpperCase()]}</div>',
'</div>',
'<div class="side-itemTemperature">{temp}°{unit}</div>',
'<div class="side-itemState">',
'<div><img src="./resources/img/rain.svg"></div>',
'<div class="side-itemDate">11:38</div>',
'</div>',
'<div class="side-itemDelete" fire="onDelete">', // <<---- here
'<img src="./resources/img/delete.svg">',
'</div>',
'</div>'
),
推荐答案
您需要指定多个侦听器:
You need to specify several listeners:
{
xtype: 'list',
listeners: [
{
event: 'tap',
fn: function(){
console.log('delete');
},
element: 'innerElement',
delegate: '.side-itemDelete'
},
{
event: 'tap',
fn: function(){
console.log('locate');
},
element: 'innerElement',
delegate: '.side-itemLocation'
}
]
}
这篇关于sencha触摸列表tpl事件参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!