开发者

Firing events on a popup window (ExtJS)

开发者 https://www.devze.com 2023-01-12 22:22 出处:网络
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).

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).

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

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.

Any help is appreciated.

(*) Yes, there's a good reason开发者_运维问答 for that. And no, Ext.Window is not an option.


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

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 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.

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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号