【问题标题】:dojo.connect not working for onClick event (in Internet Explorer)dojo.connect 不适用于 onClick 事件(在 Internet Explorer 中)
【发布时间】:2013-07-21 11:38:09
【问题描述】:

我添加了dojo.connect这样的声明,

dojo.connect(dojo.byId(this._paramsForm), "onChange", this, "_handleUpdate");

此时,当我浏览器调试并检查值时,this._paramsForm 具有有效值。 但是当事件被触发时,onChange 函数不会被调用。 dojo.connect语句肯定有问题,但是查不到。

这个也试过了,没有运气:(

dojo.connect(this._paramsForm, "onChange", this, "_handleUpdate");

也参考了这个链接,没有运气 dojo.connect won't connect 'onclick' with button

但同样的事情在 Chrome 和 Firefox 中运行得非常好。

请帮我解决这个问题!

【问题讨论】:

  • 你使用的是什么版本的Dojo

标签: javascript event-handling dojo internet-explorer-8 dom-events


【解决方案1】:

我认为您注册事件处理程序的方式是错误的 - 试试这个:

require('dojo/_base/lang', 'dojo/on');

on(this._paramsForm, "change", lang.hitch(this, _handleUpdate));

请注意,在最新版本中,前缀“on”已被删除——您只需要使用“click”、“change”等;作为事件名称。 lang.hitch - 确保 _handleUpdate 在 'this' 的上下文中执行。

如果您使用的是旧版本的dojo(

dojo.connect(this._paramsForm, "onChange", dojo.hitch(this, _handleUpdate));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多