Forum: Ruby on Rails in_place_editor_field inside a partial collection

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joon L. (Guest)
on 2005-11-14 04:29
(Received via mailing list)
(I've already posted this to a quite unrelated thread. Sorry for those
reading this twice.)

Did anybody succeeded in using "in_place_editor_field" inside a
partial collection?
It's working perfectly in a regular template, but the id part becomes
blank when it's inside a partial collection.

article_controller.rb:
class ArticleController < ApplicationController
  in_place_edit_for :comment, :body
...
end

_comment.rhtml:
<li id="comment-<%= comment.id %>">
<%= in_place_editor_field :comment, :body %>
</li>

show.rhtml:
....
<ol id="comments">
<% unless @article.comments == nil %>
<%= render :partial => "comment", :collection => @article.comments %>
<% end %>
</ol>
....

Generated HTML:
....
<li id="comment-21">
<span class="in_place_editor_field" id="comment_body__in_place_editor"
tag="span"></span><script type="text/javascript">
//<![CDATA[
new Ajax.InPlaceEditor('comment_body__in_place_editor',
'/article/set_comment_body')
//]]>
</script>
....

[comment_body__in_place_editor] should be
[comment_body_21_in_place_editor].
Apparently, the id is not set properly.

More odd thing is that when a comment is added using AJAX, above code
is working again.

I also tried to include :id as follows:
<%= in_place_editor_field :comment, :body, { :id => comment.id } %>

But in this case, [comment_body__in_place_editor] only becomes [21],
but not [comment_body_21_in_place_editor]


Here are the docs for InPlaceEditing:
http://rails.rubyonrails.com/classes/ActionControl...
http://rails.rubyonrails.com/classes/ActionView/He...

What am I missing here?

--Joon
This topic is locked and can not be replied to.