I wanted to get the community opinion on the best way to use partials
and
inline list (
I have a very common scenario where a list is rendered:
— index.rhtml —
-
<%= render :partial => 'item', @collection => @items %>
— _item.rhtml (simplified) —
I am using RJS templates to populate the ‘edit_item’ div on an ajax call
from the ‘edit’ link. All very straightforward stuff. The problem is
on
update in my RJS template I want to render the partial again to update
the
list item like this:
— update.rjs —
page.replace_html “item_” + item.id.to_s, :partial => ‘item’
The problem of course is that then you have nested
inner text is replaced, not the entire tag. Has anyone else encountered
this and come up with an elegant solution. I suppose I could strip the
outer
page.replace_html “item_” + item.id.to_s,
my_method_that_strips_the_outer_li( render :partial => ‘item’)
But I have a feeling that there is a much more elegant way to do this.
Ideas?
Thanks,
Zack