(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/ActionController/Macros/InPlaceEditing/ClassMethods.html
http://rails.rubyonrails.com/classes/ActionView/Helpers/JavaScriptMacrosHelper.html#M000367
What am I missing here?
--Joon