page.replace_html

Hello guys

I have animals/index.html.erb        <p>   <%= link_to_remote('List',:update => 'cont', :url => {:action => :list})%> </p> <div id="cont">   <p>page list</p> </div>

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

And animals/_list.html.erb <table>   <tr>     <th>Name</th>     <th>Desc</th>   </tr>

<% @animals.each do |animal| %>   <tr>     <td><%=h animal.name %></td>     <td><%=h animal.desc %></td>     <td><%= link_to 'Show', animal %></td>     <td><%= link_to 'Edit', edit_animal_path(animal) %></td>     <td><%= link_to 'Destroy', animal, :confirm => 'Are you sure?', :method => :delete %></td>   </tr> <% end %> </table> <%= 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

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 )