How to add link_to_remote element with RJS?

Hello,

after executing an action, I add an <li> element to an existing list using a RJS template:

page.insert_html :bottom, :contributors, "<li id='contributor.#{@contributor.id}'>#{@contributor.user.name}</li>"

but I need to add an image with a link_to_remote as I have in a partial page:

     <li id="contributor.<%= contributor.id %>">          <%= link_to_remote image_tag('delete.png', :size => '16x16', :alt => 'Destroy'),                             :url => {:action => "delete_contributor", :id => @project,                             :contributor_id => contributor.id},                             :method => :put %>          <%= contributor.user.name %>      </li>

How could I do this with RJS?, is it possible?

Try using a partial

page.insert_html :bottom, :contributors, :partial => 'partial_name'

As far as I know it can be done either way, but I second the partial idea. It'll keep the rjs file a lot cleaner, and be much easier to maintain.

-- Josh

Christopher Kintner wrote: