# RJS and Greybox : executing the js in the parent window?

**URL:** <https://www.ruby-forum.com/t/rjs-and-greybox-executing-the-js-in-the-parent-window/58821>\
**Category:** Rails\
**Created:** [April 26, 2006, 8:45am UTC](https://www.ruby-forum.com/t/rjs-and-greybox-executing-the-js-in-the-parent-window/58821 "2006-04-26T08:45:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aravet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@aravet](https://www.ruby-forum.com/u/aravet)\
**Post date:** [April 26, 2006, 8:45am UTC](https://www.ruby-forum.com/t/rjs-and-greybox-executing-the-js-in-the-parent-window/58821/1 "2006-04-26T08:45:49Z")

</div>

Hi all,

Question:  
Can a child window manipulate its parent window with RJS?

Example:  
In an application a parent/master window shows a list of records. When  
the users press ‘edit’, a greybox windows pops up where they can update  
one item attributes.  
Problem: after the ‘save’ and child window closing, the parent window  
still contains the old attributes values.

I know how to trigger plain javascript execution in the parent, to clean  
the parent window f.ex, but RJS is really what I need.

Is that possible?  
TIA

Alain

---

<div class="post-metadata">

**Author:** ![aravet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@aravet](https://www.ruby-forum.com/u/aravet)\
**Post date:** [April 26, 2006, 2:32pm UTC](https://www.ruby-forum.com/t/rjs-and-greybox-executing-the-js-in-the-parent-window/58821/2 "2006-04-26T14:32:56Z")

</div>

> Question:  
> Can a child window manipulate its parent window with RJS?

As a workaround, I have the children execute some javascript code  
that in turn has the parent execute some javascript code where I  
inserted an Ajax call to a controller action that refreshes the parent  
contents.

=\> when the user submit the action in the child/greybox window, it  
calls an action :

file:contact\_controller.rb  
def update  
…  
render :partial =\>  
‘hide\_greybox\_and\_refresh\_details\_in\_parent’  
…  
end

file: \_hide\_greybox\_and\_refresh\_details\_in\_parent.rhtml:

, and the parent page html starts with:

My question: is there a way to execute one single RJS call in the  
‘update’ function above, that would do the same as this 3-part action?

---

<div class="post-metadata">

**Author:** ![aravet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/49beb7/32.png) [@aravet](https://www.ruby-forum.com/u/aravet)\
**Post date:** [April 4, 2008, 6:17pm UTC](https://www.ruby-forum.com/t/rjs-and-greybox-executing-the-js-in-the-parent-window/58821/3 "2008-04-04T18:17:26Z")

</div>

Hello Alain

I’m right looking to obtain the same behavior.  
In the meantime, did you found a solution with RJS?

Thanks,  
Franco
