# Update view after insert

**URL:** <https://www.ruby-forum.com/t/update-view-after-insert/134294>\
**Category:** Rails\
**Created:** [April 9, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294 "2008-04-09T16:51:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 9, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/1 "2008-04-09T16:51:00Z")

</div>

Hi i’m trying to update a select box with a newly created record, the  
problem is that to create this record i open a popup window.

How can I update the select box with the record information created in  
the popup window, is there a way to observer model changes and updates  
the view based on that changes?

Please I really need help on this, I read a lot of forum and articles  
and i could not find anything.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 9, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/2 "2008-04-09T18:58:17Z")

</div>

Jesus bernardo Ruiz flores wrote:

> Hi i’m trying to update a select box with a newly created record, the  
> problem is that to create this record i open a popup window.
> 
> How can I update the select box with the record information created in  
> the popup window, is there a way to observer model changes and updates  
> the view based on that changes?
> 
> Please I really need help on this, I read a lot of forum and articles  
> and i could not find anything.

Are you trying to update the select field without reloading the page? If  
so, you’ll need to use JavaScript.

I recommend jQuery ([http://jquery.com](http://jquery.com)), but Rails comes with Prototype  
([http://prototypejs.org](http://prototypejs.org)).

If you have nil experience with JavaScript and you’re pressed for time  
(or are impatient) I recommend forgoing the Ajax experience and  
reloading the page.

Hope that helps, if not, respond with more information. 🙂

---

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 10, 2008, 8:53am UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/3 "2008-04-10T08:53:40Z")

</div>

You need a remote\_form (ie AJAX) that updates the element in the  
(named) original form of the window that calls the popup.

Just to make perfectly clear, you need to set the html NAME and ID  
property of the form tag on the page that calls the pop-up window,  
because the pop up window has to reference inside of that form to  
update the select tag.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
VIDEO #3 out NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 10, 2008, 9:38pm UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/4 "2008-04-10T21:38:12Z")

</div>

Julian L. wrote:

> You need a remote\_form (ie AJAX) that updates the element in the  
> (named) original form of the window that calls the popup.
> 
> Just to make perfectly clear, you need to set the html NAME and ID  
> property of the form tag on the page that calls the pop-up window,  
> because the pop up window has to reference inside of that form to  
> update the select tag.
> 
> Julian.
> 
> Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
> VIDEO #3 out NOW!  
> [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

Sorry to bother you with this, but can you send me an example of how to  
do this?

Thank ypu very much

---

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 11, 2008, 4:25am UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/5 "2008-04-11T04:25:06Z")

</div>

Not unless you’re prepared to pay me to do it, unfortunately.

I may release a video on how to do it sometime.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)  
VIDEO #3 out NOW!  
[http://sensei.zenunit.com/](http://sensei.zenunit.com/)

---

<div class="post-metadata">

**Author:** ![jessruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d6d6ee/32.png) [@jessruby](https://www.ruby-forum.com/u/jessruby)\
**Post date:** [April 10, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/update-view-after-insert/134294/6 "2008-04-10T21:14:10Z")

</div>

Daniel W. wrote:

> Are you trying to update the select field without reloading the page? If  
> so, you’ll need to use JavaScript.
> 
> I recommend jQuery ([http://jquery.com](http://jquery.com)), but Rails comes with Prototype  
> ([http://prototypejs.org](http://prototypejs.org)).
> 
> If you have nil experience with JavaScript and you’re pressed for time  
> (or are impatient) I recommend forgoing the Ajax experience and  
> reloading the page.
> 
> Hope that helps, if not, respond with more information. 🙂

Yes i’m trying to update the select field without reloading the page.  
I’ll check the prototype
