我有一个带有敲击监听器(红色方块)的面板,上面还有一个按钮(绿色)。像这样的东西:
当按钮被按下时,我想避免红色方块的点击监听器,但我找不到这样做的方法。你可以帮帮我吗?
这个例子不完全是我的代码(我使用 Controller 、数据项等)但是是同样的问题:http://jsfiddle.net/6ah6U/
Ext.Viewport.add({
xtype: 'panel',
height: 300,
width: 300,
style: 'background: #ff0000',
items: [{
xtype: 'panel',
height: 50,
width: 50,
style: 'background: #00ff00',
listeners: {
tap: function() {
console.log('green tapped');
},
element: 'element'
},
}],
listeners: {
tap: function() {
console.log('red tapped');
},
element: 'element'
},
});
谢谢!
最佳答案
只需在绿色面板上处理点击事件的函数中停止事件的传播:
tap: function(btn, e) {
alert('green tapped');
e.stopPropagation();
},
希望这可以帮助
关于sencha-touch-2 - 在另一个组件上管理一个组件上的点击事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15380844/