# Page.replace\_html

**URL:** <https://www.ruby-forum.com/t/page-replace-html/174016>\
**Category:** Rails\
**Created:** [August 19, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/page-replace-html/174016 "2009-08-19T15:00:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 19, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/page-replace-html/174016/1 "2009-08-19T15:00:47Z")

</div>

Hello guys

I have animals/index.html.erb

\<%= link\_to\_remote(‘List’,:update =\> ‘cont’, :url =\> {:action =\>  
:list})%\>

page list

And animals/list.html.erb

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

And animals/\_list.html.erb

\<% @animals.each do |animal| %\>

\<% end %\>

| Name | Desc |
| --- | --- |
| \<%=h animal.name %\> | \<%=h animal.desc %\> | \<%= link\_to 'Show', animal %\> | \<%= link\_to 'Edit', edit\_animal\_path(animal) %\> | \<%= link\_to 'Destroy', animal, :confirm =\> 'Are you sure?', :method =\> :delete %\> |

\<%= will\_paginate @animals %\>

and controller

def list  
@animals = Animal.paginate(:page =\> params[:page], :per\_page =\> 3)  
respond\_to do |format|  
format.html  
format.js {  
render :update do |page|  
page.replace\_html ‘cont’, :partial =\> ‘list’  
end  
}  
end  
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:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 19, 2009, 6:14pm UTC](https://www.ruby-forum.com/t/page-replace-html/174016/2 "2009-08-19T18:14:09Z")

</div>

You are two different ways to update your

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 )

On Aug 19, 6:00 am, Wap A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 20, 2009, 7:46am UTC](https://www.ruby-forum.com/t/page-replace-html/174016/3 "2009-08-20T07:46:39Z")

</div>

Hi hitch

i can try to follow your suggestion but this not to be done proper so  
that if you have any example. please give me for refer
