# Submitting a popup

**URL:** <https://www.ruby-forum.com/t/submitting-a-popup/127832>\
**Category:** Rails\
**Created:** [February 1, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832 "2008-02-01T17:50:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 1, 2008, 5:50pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/1 "2008-02-01T17:50:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 1, 2008, 7:36pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/2 "2008-02-01T19:36:42Z")

</div>

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.

On Feb 1, 11:49 am, “removed\_email\_address@domain.invalid”

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 1, 2008, 7:38pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/3 "2008-02-01T19:38:27Z")

</div>

RedBox not Redcloth. Sorry.

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 1, 2008, 8:01pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/4 "2008-02-01T20:01:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 1, 2008, 10:54pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/5 "2008-02-01T22:54:22Z")

</div>

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?

On Feb 1, 2:01 pm, Wouter de Bie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 3, 2008, 4:38pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/6 "2008-02-03T16:38:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 4, 2008, 5:57pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/7 "2008-02-04T17:57:47Z")

</div>

Hi,

I am getting this error method while trying this approach.  
undefined local variable or method `page’ for #\<#Class:0x48b145c:  
0x48b140c\>

Neha

On Feb 3, 10:38 am, Wouter de Bie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![neha-rohan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neha-rohan](https://www.ruby-forum.com/u/neha-rohan)\
**Post date:** [February 4, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/submitting-a-popup/127832/8 "2008-02-04T17:54:10Z")

</div>

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.

On Feb 1, 2:01 pm, Wouter de Bie [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
