DOM事件和sencha事件之间的事件顺序
我有一个数据视图,它是用extjs 7.1 modern takeit编写的,带有一个带有 anchor标记和一个 select 事件的模板:
I've a dataview, written with extjs 7.1 modern tookit, with a template with an anchor tag and a select event:
https://fiddle.sencha.com/#view/editor&fiddle/34bd
Ext.create({
renderTo: document.body,
xtype: 'list',
itemTpl: '<div class="contact"><a onclick="event.preventDefault();console.log(\'link\');" href="{firstName}">{firstName}</a> <b>{lastName}</b></div>',
store: {
data: [{
firstName: 'Peter',
lastName: 'Venkman'
}, {
firstName: 'Raymond',
lastName: 'Stantz'
}, {
firstName: 'Egon',
lastName: 'Spengler'
}, {
firstName: 'Winston',
lastName: 'Zeddemore'
}]
},
listeners: {
select() { console.log('select'); }
}
});
我希望链接事件将在列表选择事件之前被触发,但是相反的情况发生了,甚至最坏的两个事件都将被依次触发.
I expect the link event will be fired before the list select event, but the opposite happens and even worst both events will be fired one after another.
我试图按照您的建议理解用户点击的位置,但我不知道如何.
I'm trying to understand where the user clicks as you suggest but I don't know how.
正如@LightNight所说,可以在选择之前使用 childtap
事件运行所需的处理程序.如果您想了解点击发生在何处-只需使用 event.target
.看我的示例
As @LightNight said, you can use childtap
event to run needed handler before select. If you want to understand where the click occurred - just use event.target
. Look my example