Hi,
I got stuck by some window to window communication issue.
I have a main window witch open a popup window with window#open
method. The popup contains a small form.
In onsubmit handler ot that form I generate a custom event, say
'vera:euChosen', with a complicated memo.
I fire it with
Element.fire(window.opener.document, 'vera:euChosen', memo);
I also do
document.observe('vera:euChosen',refToMyHandler);
in parent window. Now I get a result I do not understand.
When the event is fired, the refToMyHandler(evnt) is executed, but
the evnt is of type 'dataavailable' and there is no trace of my memo.
Am I doing something wrong, or one just can't pass a custom event
between two windows (even if the firing window is opened by the
listening window)?
I tried also to fire the event on a popup window and listen on it.
I tried both window.document documents and I always get dataavailable
and not my custom event.
How can I transwer my memo object to my main window (window.opener)
without knowledge of any js function or element of main window in my
popup window? I need to use this popup in several pages, and would
like just to pass my data, to any main window. Main window's scripts
should decide what to do with them.
Any suggestions?
Regards,
Szymon Wilko³azki
on 2008-07-04 16:41
on 2008-07-04 18:17
Szymon, All custom events are piggybacked on "dataavailable" and are injected with "memo" property on an event object itself. As far cross-window messaging, I don't think this is possible with current implementation. Custom events simply bubble up to a top level element in the scope of the window that originated event. -- kangax
on 2008-07-07 12:48
Hi, kangax wrote: > All custom events are piggybacked on "dataavailable" and are injected > with "memo" property on an event object itself. As far cross-window > messaging, I don't think this is possible with current implementation. > Custom events simply bubble up to a top level element in the scope of > the window that originated event. > Thanks for your reply. I tested it a bit more and it turns out, that I can get the dataavailable event *with* the memo *if* I open popup window with incorrect html, without all the <html><head><body> tags, just the html content. It's a little weird for me. Anyway I do not want to do that, so I decided to use ajax instead popup, even if it means breaking our app "standards" (this is a very old web app, lots of things are done in popups). Of course there is no problem with custom events fired from ajax loaded content. My problem disappeared :) Thanks again, Szymon Wilko³azki