# How to refresh a parent page

**URL:** <https://www.ruby-forum.com/t/how-to-refresh-a-parent-page/185214>\
**Category:** Rails\
**Created:** [March 16, 2010, 8:12am UTC](https://www.ruby-forum.com/t/how-to-refresh-a-parent-page/185214 "2010-03-16T08:12:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [March 16, 2010, 8:12am UTC](https://www.ruby-forum.com/t/how-to-refresh-a-parent-page/185214/1 "2010-03-16T08:12:07Z")

</div>

Hi Guys,

I have the fllowing requirement,

I have a model called Task to display user tasks

1 . Link to add a new task (in the tasks index page)  
2 . when a user click the link, ‘tasks/new’ action will open up inside a  
popup  
3 . when the user save the new task, I want to close ‘new task’ popup  
and refresh the  
parent page ‘tasks/index’ so that new task will display

I guess, i will have to execute a page reload java script at the end of  
‘tasks/create’ action. But i’m not sure how to.

can anyone help me out to make this happen, thanks in advance

cheers,  
sameera

---

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [March 16, 2010, 2:55pm UTC](https://www.ruby-forum.com/t/how-to-refresh-a-parent-page/185214/2 "2010-03-16T14:55:06Z")

</div>

Sameera G. wrote:

> Hi Guys,
> 
> I have the fllowing requirement,
> 
> I have a model called Task to display user tasks
> 
> 1 . Link to add a new task (in the tasks index page)  
> 2 . when a user click the link, ‘tasks/new’ action will open up inside a  
> popup

What sort of popup? Are you opening a new browser window or is this an  
AJAX style popup?

> 3 . when the user save the new task, I want to close ‘new task’ popup  
> and refresh the  
> parent page ‘tasks/index’ so that new task will display
> 
> I guess, i will have to execute a page reload java script at the end of  
> ‘tasks/create’ action. But i’m not sure how to.

This depends on how you plan to implement your popup. If you use a  
separate browser window then you could use JavaScript to update your  
“parent” window.

Since you’d be using JavaScript already you might instead use an AJAX  
style popup and have only a single browser window to deal with. You  
could perform all your updating with Prototype or jQuery by manipulating  
the DOM directly.

The point is that there’s a few different options and it depends on  
which one you choose.
