在弹出窗口(ExtJS)上启动事件 [英] Firing events on a popup window (ExtJS)

查看:140
本文介绍了在弹出窗口(ExtJS)上启动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个广泛使用弹出窗口(*)的应用程序,并在IE中遇到问题(已经报告了之前,showthread.php?65068-Ext.util.Observable-addListener-bug-with-IE& daysprune = -1rel =nofollow noreferrer>,但我找不到任何解决方案)。

we're currently developing an application that makes extensive use of popup windows(*) and have run into an issue on IE (this has been reported before but I couldn't find any solution).

问题是这样的:我们的主窗口 M 打开一个弹出窗口 P ,并保留其引用。然后, P M 中的对象上注册一个事件处理程序。当事件触发时,IE8会弹出以下错误消息:

The problem is this: our main window M opens a popup window P and keeps a reference to it. P then registers an event handler on an object in M. When the event fires, IE8 bombs out with the following error message:

JScript object expected
ext-all-debug.js (Line 1735, Char 17)
Code: 0

EXTUTIL.Event.prototype 中的函数。该代码在Firefox,Opera和Chrome中正常工作。

which is the fire-function in EXTUTIL.Event.prototype. The code works fine in Firefox, Opera and Chrome.

我提供了一个最小例子产生这种行为。

I've provided a minimal example that produces this behaviour.

任何帮助都不胜感激。

(*)是的,有一个很好的理由。不,Ext.Window不是一个选项。

(*) Yes, there's a good reason for that. And no, Ext.Window is not an option.

推荐答案

嗯,至少我得到了滚滚徽章。 : - )

Well, at least I got the tumbleweed badge. :-)

事实证明,您不能使用ExtJS在IE浏览器窗口中触发事件。来自ExtJS社区支持团队的秃鹰说:

As it turns out, you can not use ExtJS to fire events across browser windows in IE. Condor from the ExtJS Community Support Team said:


Ext是不安全的在Windows之间使用。每个窗口应该有它自己的Ext实例,两个窗口之间的通信只能使用原始数据类型(String,Number,Boolean,Date)完成。

Ext is NOT safe to be used across windows. Each window should have it's own Ext instance and communication between the two windows should only be done using primitive datatypes (String, Number, Boolean, Date).

这意味着你不能在不同的窗口中注册一个事件处理程序,因为这意味着将对象传递到另一个窗口。

This means that you can't register an event handler in a different window, because that would mean passing objects to the other window.

事实证明,这并不完全准确(至少在IE7及以上)。您可以在浏览器窗口中引用对象。你不能使用Ext事件系统。

As it turns out, this is not entirely accurate (at least in IE7 and above). You can reference objects across browser windows. What you can't do is use the Ext event system.

我使用的解决方法是,而不是在 P 中注册事件处理程序,以使 M 调用方法在 P ,然后在本地启动事件。它当然不是很优雅或灵活,但它在所有浏览器中都能很好地工作。此外,我认为保持跨窗口通信简单明了的做法是很好的做法。如果您使用事件处理程序,则必须仔细跟踪发生的情况,例如,您需要确保在窗口关闭之前注销所有事件处理程序。

The workaround I used is, instead of registering event handlers in P, to have M call methods in P that then fire the events "locally". It is, of course, not quite es elegant or flexible, but it does work nicely in all browsers. Besides, I think it is good practice to keep cross-window-communication simple and well defined. If you use event handlers you have to carefully keep track of what happens where, for instance you need to make sure you unregister all event handlers before the window is closed.

这篇关于在弹出窗口(ExtJS)上启动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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