At times I use partials to render pieces of a form like this
<% form_for @foo do |f| %>
...
<div id="foo">
<%= render :partial => ''foo'', :locals => { :f
=> f } %>
</div>
...
<% end %>
def edit
@foo = ...
respond_to do |format|
format.html
end
end
That works nicely, of course. However, I hit a snag when I want to use
that partial in an ajax request to update something inside the form.
There, I need to pass in something comparable to the FormBuilder (f)
passed into the partial from within the complete view.
I''ve worked around this by wrapping the partial into another one like
so
# _foo_update.html.erb
<% fields_for @foo do |f| %>
<%= render :partial => ''foo'', :locals => { :f =>
f } %>
<% end %>
and then use
page.replace_html ''foo'', :partial =>
''foo_update''
I don''t particularly like this as I often don''t use plain
form_for/fields_for. Rather, I parameterize them with custom
FormBuilders (for labelling, say) and I''d prefer to do that in only a
single place. At any rate, I''d like to get rid of the wrapper partial.
Any ideas?
Michael
--
Michael Schuerig
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org
http://www.schuerig.de/michael/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---