SWilk
2008-Jul-04 14:41 UTC
Custom event from subwindow handled in opening window - possible?
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
kangax
2008-Jul-04 16:16 UTC
Re: Custom event from subwindow handled in opening window - possible?
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 Jul 4, 10:41 am, SWilk <wilkola...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
SWilk
2008-Jul-07 10:47 UTC
Re: Custom event from subwindow handled in opening window - possible?
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> > On Jul 4, 10:41 am, SWilk <wilkola...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> 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 > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---