【发布时间】:2011-06-23 16:09:13
【问题描述】:
我的按钮处理程序被调用了两次 - 一次用于 mousedown/touchstart,第二次用于 mouseup/touchend。
这发生在我的 iPhone 设备和我的 Chrome 浏览器中。
使用 ST 1.1
我没有找到任何关于这个问题的参考,这似乎表明我的环境中的某些东西是错误的,但是我没有东西可以检查了......
在 Chrome DevTools 中检查传递给处理程序的事件对象,我可以看到它们都是模拟的“tap”事件,第一个来自“mousedown”,第二个来自“mouseup”。
有什么想法吗?
编辑:
我发现当我向Ext.EventManager.onDocumentReady 添加一个调用(即使是一个空的处理程序)时会发生这种情况。
如果我删除此调用,我只会按预期获得对“mouseup”的点击。
如果我用Ext.onReady 替换它,它就可以工作!!!
这真是令人困惑,因为一个是另一个的别名......
代码复制:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="resources/Sencha/sencha-touch-debug.js" type="text/javascript"></script>
<link href="resources/Sencha/sencha-touch.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
MyPanel = Ext.extend(Ext.Panel, {
fullscreen: true,
initComponent: function() {
this.items = [{
xtype: 'button',
text: 'Login',
handler: this.myHandler,
scope: this
}];
MyPanel.superclass.initComponent.apply(this, arguments);
},
myHandler: function(b, e) {
console.log(e.event.type);
}
});
Ext.EventManager.onDocumentReady(function() {
});
Ext.onReady(function() {
new MyPanel();
});
</script>
</head>
<body></body>
</html>
【问题讨论】:
-
你能提供一些示例代码吗?
-
或者示例的实时链接也可以使用-
-
添加重现代码+导致根因
-
嗨。你找到解决方案了吗?
-
@kalyanipuvvada 我不记得找到原因了,但我认为使用“Ext.onReady”而不是“Ext.EventManager.onDocumentReady”的解决方法对我来说已经足够了。
标签: sencha-touch