Page.replace_html

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

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. [email protected]

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs