Dojo.Connect事件不会被调用 - 为什么? [英] Dojo.Connect Event doesn't get called - why?

查看:89
本文介绍了Dojo.Connect事件不会被调用 - 为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 onMouseDown 事件连接到具有 dojo.connect 的图像,如:

I am trying to connect an onMouseDown event to an image with dojo.connect like:

dojo.connect(dojo.byId("workpic"), "onMouseDown", workpicDown);

function workpicDown()
{
    alert("mousedown");
}

几行之后的类似代码,我连接的地方 onMouse * 事件到 dojo.body 正常工作。

Similar code a few lines later, where I'm connecting onMouse* events to dojo.body does work completely properly.

当我点击图像时,我没有看到警报窗口,所以事件没有被调用。为什么是这样?

but when I click on the image, I'm not seeing the alert window, so the event doesn't get called. Why is that?

推荐答案

onMouseDown应该与使用DOM事件而不是Widget事件一起使用。尝试:

"onMouseDown" should be all lower case when used with DOM events as opposed to Widget events. Try:

dojo.connect(dojo.byId("workpic"), "onmousedown", workpicDown);

文档


有关事件名称的事件:事件
名称现在是小写,除了
特殊情况(例如,一些Mozilla DOM
事件)。如果您将其关闭(例如
'click'和'onclick')与Dojo相同的
事情,Dojo会将on添加到
事件名称。这不同于
Widget事件在意义上Dijit使用
mixedCase事件名称,以避免
潜在冲突。

A note about the event names: Event names now are lower case, except in special cases (e.g., some Mozilla DOM events). Dojo will add "on" to your event name if you leave it off (e.g., 'click' and 'onclick' are the same thing to dojo). This differs from Widget Events in the sense Dijit uses mixedCase event names, to avoid potential conflicts.

这篇关于Dojo.Connect事件不会被调用 - 为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆