# Move data from popup back to main window

**URL:** <https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496>\
**Category:** Rails\
**Created:** [January 9, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496 "2008-01-09T17:47:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 9, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/1 "2008-01-09T17:47:44Z")

</div>

Anyway to do this without using an rjs file? Otherwise, I’m guessing  
AJAX is the only way.

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 9, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/2 "2008-01-09T19:00:26Z")

</div>

You can reload the main window. You can do this by redirecting to the  
action that displays the main window after processing the popup post  
request.

On Jan 9, 11:47 am, Corey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 9, 2008, 7:25pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/3 "2008-01-09T19:25:49Z")

</div>

On 9 Jan 2008, at 17:48, eggman2001 wrote:

> You can reload the main window. You can do this by redirecting to the  
> action that displays the main window after processing the popup post  
> request.
> 
> On Jan 9, 11:47 am, Corey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Anyway to do this without using an rjs file? Otherwise, I’m guessing  
> > AJAX is the only way.

the child window can call functions from the parent window. I’ve got  
an app where the user can open a popup window, do some searching and  
when they’ve found something they like the look of, the button they  
click just does parent.some\_function(…)

Fred

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 9, 2008, 7:42pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/4 "2008-01-09T19:42:19Z")

</div>

eggman2001 wrote:

> You can reload the main window. You can do this by redirecting to the  
> action that displays the main window after processing the popup post  
> request.
> 
> On Jan 9, 11:47 am, Corey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

This I’ve tried and the redirect ends up loading the correct screen but  
instead of refreshing or loading it in the main window, it loads it in  
the popup window instead. Here is the code:

def processSelection  
if request.post?  
id = params[:id]  
redirect\_to(:controller =\> ‘screens’, :action =\> :new, :bbID =\> id)  
end  
end

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 10, 2008, 9:18am UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/5 "2008-01-10T09:18:45Z")

</div>

On 9 Jan 2008, at 18:44, Corey M. wrote:

> > > On Jan 9, 11:47 am, Corey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > > Fred
> 
> Are you just calling a method/function in the controller of the  
> parent?  
> Or are you actually posting form data to some method? I guess it  
> wouldn’t matter, but either way you have to somehow close the popup.

Neither. Pure javascript here.

you can call window.close to close yourself, and if on the parent you  
have

Then you can call parent.fromChild(…)

Fred

---

<div class="post-metadata">

**Author:** ![rubylicious](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/91b2a8/32.png) [@rubylicious](https://www.ruby-forum.com/u/rubylicious)\
**Post date:** [January 9, 2008, 7:44pm UTC](https://www.ruby-forum.com/t/move-data-from-popup-back-to-main-window/125496/6 "2008-01-09T19:44:03Z")

</div>

Frederick C. wrote:

> On 9 Jan 2008, at 17:48, eggman2001 wrote:
> 
> > You can reload the main window. You can do this by redirecting to the  
> > action that displays the main window after processing the popup post  
> > request.
> > 
> > On Jan 9, 11:47 am, Corey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > wrote:
> > 
> > > Anyway to do this without using an rjs file? Otherwise, I’m guessing  
> > > AJAX is the only way.
> 
> the child window can call functions from the parent window. I’ve got  
> an app where the user can open a popup window, do some searching and  
> when they’ve found something they like the look of, the button they  
> click just does parent.some\_function(…)
> 
> Fred

Are you just calling a method/function in the controller of the parent?  
Or are you actually posting form data to some method? I guess it  
wouldn’t matter, but either way you have to somehow close the popup.
