So I''ve been following various tutorials to implement an ajax-like file
upload using responds_to_parent and iframe targets, but can''t quite
close the deal. My file uploads successfully, but the rjs doesn''t work
(my ''events'' partial, which refreshes fine with this
controller code
when called with form_remote_tag, doesn''t refresh).
Can anyone who''s done this before see what''s missing?
Thanks,
Peter
View:
<% form_tag({:action=>''upload''}, :multipart => true,
:target => "frame")
do %>
<%= file_field_tag "uploaded_file" %>
<%= submit_tag ''Upload'' %>
<% end %>
<iframe style="width: 0; height: 0; border: 0;"
id=''frame''
name="frame"></iframe>
Controller:
def upload
event = Event.new
event.date = Date.today
if event.save
File.open("#{RAILS_ROOT}/uploaded.rtf", "wb") do |f|
f.write(params[''uploaded_file''].read)
end
responds_to_parent do
render :update do |page|
page.replace_html "event_list", :partial =>
"events"
end
end
end
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---