# page.replace\_html

**URL:** <https://discuss.rubyonrails.org/t/page-replace-html/45286>\
**Category:** rubyonrails-talk\
**Created:** [August 19, 2009, 1:00pm UTC](https://discuss.rubyonrails.org/t/page-replace-html/45286 "2009-08-19T13:00:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11175](https://avatars.discourse-cdn.com/v4/letter/1/8edcca/32.png) [@11175](https://discuss.rubyonrails.org/u/11175)\
**Post date:** [August 19, 2009, 1:00pm UTC](https://discuss.rubyonrails.org/t/page-replace-html/45286/1 "2009-08-19T13:00:47Z")

</div>

Hello guys

I have animals/index.html.erb &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<p\> &nbsp;&nbsp;\<%= link\_to\_remote('List',:update =\> 'cont', :url =\> {:action =\> :list})%\> \</p\> \<div id="cont"\> &nbsp;&nbsp;\<p\>page list\</p\> \</div\>

And animals/list.html.erb &nbsp;&nbsp;\<div id="cont"\> &nbsp;&nbsp;\<%= render :partial =\> 'list'%\> \</div\>

And animals/\_list.html.erb \<table\> &nbsp;&nbsp;\<tr\> &nbsp;&nbsp;&nbsp;&nbsp;\<th\>Name\</th\> &nbsp;&nbsp;&nbsp;&nbsp;\<th\>Desc\</th\> &nbsp;&nbsp;\</tr\>

\<% @animals.each do |animal| %\> &nbsp;&nbsp;\<tr\> &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<%=h animal.name %\>\</td\> &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<%=h animal.desc %\>\</td\> &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<%= link\_to 'Show', animal %\>\</td\> &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<%= link\_to 'Edit', edit\_animal\_path(animal) %\>\</td\> &nbsp;&nbsp;&nbsp;&nbsp;\<td\>\<%= link\_to 'Destroy', animal, :confirm =\> 'Are you sure?', :method =\> :delete %\>\</td\> &nbsp;&nbsp;\</tr\> \<% end %\> \</table\> \<%= will\_paginate @animals %\>

and controller

def list &nbsp;&nbsp;&nbsp;&nbsp;@animals = Animal.paginate(:page =\> params[:page], :per\_page =\> 3) &nbsp;&nbsp;&nbsp;&nbsp;respond\_to do |format| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.html &nbsp;&nbsp;&nbsp;&nbsp;format.js { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :update do |page| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;page.replace\_html 'cont', :partial =\> 'list' &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

then i got following o/p try { Element.update("cont", " \n \n Name\n Desc\n \n\n\n \n dog\n dog\n Show\n Edit\n \\n \\n Name\\n Desc\\n \\n\\n\\n \\n dog\\n dog\\n Show\\n Edit\\n Destroy\\n \\n\\n \\n horse\\n horse\\n Show\\n Edit\\n Destroy\\n \\n\\n \\n cow\\n cow\\n Show\\n Edit\\n Destroy\\n \\n\\n \\n « Previous 1 2 Next » \");'); throw e }

if any solution please give me

---

<div class="post-metadata">

**Author:** ![hitch](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@hitch](https://discuss.rubyonrails.org/u/hitch)\
**Post date:** [August 19, 2009, 4:12pm UTC](https://discuss.rubyonrails.org/t/page-replace-html/45286/2 "2009-08-19T16:12:39Z")

</div>

You are two different ways to update your \<div id="cont"\> 1. specify :update in your link\_to\_remote (this just displays whatever your action returns - use this when you don't have javascript you want to execute ) 2. specify "cont" in you page.replace\_html But you should not do both.

What you probably want is method 2, so you should eliminate the :update=\>'cont' from your link\_to\_remote and then you can get rid of list.html.erb (but not your partial in \_list.html.erb, since your rjs template needs it )
