# Close popup window?

**URL:** <https://www.ruby-forum.com/t/close-popup-window/170007>\
**Category:** Rails\
**Created:** [June 11, 2009, 9:10am UTC](https://www.ruby-forum.com/t/close-popup-window/170007 "2009-06-11T09:10:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![macwise](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@macwise](https://www.ruby-forum.com/u/macwise)\
**Post date:** [June 11, 2009, 9:10am UTC](https://www.ruby-forum.com/t/close-popup-window/170007/1 "2009-06-11T09:10:13Z")

</div>

I’m new to ruby, and I’m tweaking a plugin. Can you show me how I  
would close a window upon clicking a submit button? Here’s the code  
on the xhtml page: \<%= submit\_tag “Save” %\>

And the code on the controller.rb page: redirect\_to params.slice  
(:filter, :sort\_by, :key\_type, :key\_pattern, :text\_type,  
:text\_pattern).merge  
({:action =\> :index})

As I stated, I would like this last line to close instead of  
redirecting to index. Thanks!

---

<div class="post-metadata">

**Author:** ![macwise](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c2a13f/32.png) [@macwise](https://www.ruby-forum.com/u/macwise)\
**Post date:** [June 11, 2009, 10:08am UTC](https://www.ruby-forum.com/t/close-popup-window/170007/2 "2009-06-11T10:08:53Z")

</div>

On Jun 11, 6:03 am, macwise [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m new to ruby, and I’m tweaking a plugin. Can you show me how I  
> would close a window upon clicking a submit button? Here’s the code  
> on the xhtml page: \<%= submit\_tag “Save” %\>
> 
> And the code on the controller.rb page: redirect\_to params.slice  
> (:filter, :sort\_by, :key\_type, :key\_pattern, :text\_type, :text\_pattern).merge  
> ({:action =\> :index})
> 
> As I stated, I would like this last line to close instead of  
> redirecting to index. Thanks!

You’ll need some javascript to accomplish that. for an ajax form you  
could simply use the appropriate callbacks, for a non ajax form I  
suppose you could redirect to or a render a page which just had a  
small fragment of javascript that said window.close()

Fred
