javascript - mootools点击:relay not firing on ipad/iphone

标签 javascript mootools

我只是使用 mootools 创建一个点击事件,如下所示:

$$('body').addEvent('click:relay(div.smart-bg)', function(){

xxxxxxxxxxx

});

但是,这似乎不会在 iPad 上触发(而其他点击事件会触发)。这与它是添加的动态元素并且我正在使用 :relay 的事实有关吗?

非常感谢任何指点。

广告。

最佳答案

当我在 div 上添加委托(delegate)点击事件时,我遇到了类似的问题。

This article from quirksmode可能有帮助:

There must be a reason for this behaviour. I don’t know what that reason is, but currently I think that it’s a memory management problem. Apparently, making all elements on a page clickable demands too many resources, and the Apple engineers decided to disable it.

还有...

Fortunately it’s pretty easy to solve: you have to make the element clickable by giving it an onclick event handler of its very own. That handler can be empty; as long as it’s present it will make any element clickable.

也许在你的情况下......

$$('.smart-bg').each(function(el) {
    el.onclick = function() {};
});

当然,鉴于它是委托(delegate)事件,您必须确保在动态创建的每个 .smart-bg 元素上重新创建 onclick 处理程序。

关于javascript - mootools点击:relay not firing on ipad/iphone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12213944/

相关文章:

javascript - mootools 比 jquery 有什么优势?

javascript - mootools document.getelement 不是函数

javascript - 断言错误 [ERR_ASSERTION] : Task function must be specified

javascript - $regex 如何在 mongoose 中以空值工作

javascript - 使用 sendgrid 发送带有图像的邮件

php - 如何使用 livevalidation javascript 库 custom.validation 函数?

javascript - 资源解释为样式表但使用 MIME 类型文本/javascript 传输

javascript - 将小图像拉伸(stretch)到窗口

Javascript : "[classname] is not defined" error

javascript - 如何解决 jQuery 和 mootoools 冲突?