Submitting a popup

Hi,

I wanted to discuss one scenario.

From a main window, I open a javascript popup window, in that i have a
form_remote_tag call.
On the completion of this call, i want some server side code to
execute and form to be submitted, after that is done i want the pop up
window to close and after that a DOM element to be updated in the main
window.

So am having trouble with the last part i.e. updating a DOM in my main
window.
So how can i make it work.

Thanks in advance.

Neha

Sorry I don't have a direct answer for you, but you could make a CSS
style popup in the main window using something like Redcloth. Then you
don't have to worry with two windows.

RedBox not Redcloth. Sorry.

I once did this:

I created a javascript function in the main window that is able to
update the DOM element. In the method that is called when submitting the
form in the popup, I returned some RJS. Here I call the javascript
function in the main window, reachable through "window.opener"

It looks something like:

page << "if(window.opener) window.opener.myUpdateFunction(someParams)"

Greetings,

Wouter

Neha Chopra wrote:

So that means that when i do the form submission, i should return some
rjs, that will automatically invoke the javascript of the main window?
How will the javascript of main window be invoked?

That's correct. The example given executes a javascript function in the
main window. When opening a popup, the popup window should have a DOM
element called "opener", through which you can reach the main window.

Hi,

I tired this today but somehow couldnt get it to work.

I invoked a popup, then on form submission from the popup i rendered
an RJS that has the code that says
page << "if(window.opener) window.opener.myUpdateFunction()"

and this myUpdateFunction() is a javascript function defined in the
layout of the main window.
but its not getting invoked.
Any thoughts on this.