# Page.replace\_html and \<table\>

**URL:** <https://www.ruby-forum.com/t/page-replace-html-and-table/160053>\
**Category:** Rails\
**Created:** [February 11, 2009, 11:04am UTC](https://www.ruby-forum.com/t/page-replace-html-and-table/160053 "2009-02-11T11:04:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [February 11, 2009, 11:04am UTC](https://www.ruby-forum.com/t/page-replace-html-and-table/160053/1 "2009-02-11T11:04:49Z")

</div>

Hello,

I have a page with a form and a div area that I update after submitting  
the form.

I want to replace the Div area with new information.

In the page, inside the div area, I have:

 \<%= render :partial =\> "list" %\>

as I want to show the current records the first time the page opens.

The problem is after submitting, I the ‘old values’ of the Div remain in  
the Div, and now I have the new values with the old values. If I  
continue to add some new values, I get always on top the new ones and  
after the ‘old ones’, I get TWO tables, the new one and the old one.

How I can remove the old table ???

If for example I add some text on the top of the \_list (partial included  
in the Div), this text gets removed but NOT the table.

Any ideas ?

I’m updating the div with a .js.rjs file:  
page.replace\_html(“div\_listd”, :partial =\> “list”)

If in the page I don’t put the \<%= render :partial =\> “list” %\>, I  
don’t see the inital records (correct), and subsequent forms submitted  
show the resulted records ok, so the .js can replace the content of the  
Div area …

very strange for me …

thanks,

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [February 13, 2009, 10:44am UTC](https://www.ruby-forum.com/t/page-replace-html-and-table/160053/2 "2009-02-13T10:44:12Z")

</div>

Raimon Fs wrote:

> \<%= render :partial =\> “list” %\>
> 
> don’t see the inital records (correct), and subsequent forms submitted  
> show the resulted records ok, so the .js can replace the content of the  
> Div area …

Are you sure that your HTML is correctly nested?

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [February 13, 2009, 10:48am UTC](https://www.ruby-forum.com/t/page-replace-html-and-table/160053/3 "2009-02-13T10:48:44Z")

</div>

Mark Reginald J. wrote:

> Raimon Fs wrote:
> 
> > \<%= render :partial =\> “list” %\>
> > 
> > don’t see the inital records (correct), and subsequent forms submitted  
> > show the resulted records ok, so the .js can replace the content of the  
> > Div area …
> 
> Are you sure that your HTML is correctly nested?
> 
> –  
> Rails Wheels - Find Plugins, List & Sell Plugins -  
> [http://railswheels.com](http://railswheels.com)

I hope it was … finally I did a refactoring and changed the approach,  
the problem is solved but I’m not sure where the problem was …

thanks,

r.

---

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [February 13, 2009, 10:54am UTC](https://www.ruby-forum.com/t/page-replace-html-and-table/160053/4 "2009-02-13T10:54:17Z")

</div>

Hi,

To update particular part of the page with new information, you can  
use Ajax.Updater in .js file.
