Forum: Ruby on Rails render :update / page.replace_html problem

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.
Tom H. (Guest)
on 2008-10-18 14:21
Hi there,

I have this ajax problem, I'm desparately trying to debug since 1 entire
day now:

The Controller includes:
========================

[...]
render :update do |page|
  page.replace_html 'coverletter_part', :partial =>
'user/applicationfiles/coverletter_part'
end
[...]

The View includes:
==================

[...]
<div id="coverletter_part">
</div>
[...]

The _coverletter_part partial:
==============================

<% form_for(:coverletter, :url => {
path/to/call/the/above/mentioned/controller }) do |f| -%>

  [...]

<% end -%>



Calling the controller, I get an error message *of this type* printed on
my screen:
(the actual error message is much longer, since it's filled up with lots
of stuff)

try { ...blah... } catch (e) { alert('RJS error:\n\n' + e.toString());
alert(' ...blah... '); throw e }

Why does the javascript code not get executed?
(Actually, within the same project, I've proceeded in the same exact way
to update another DIV on the same exact view, just before calling the
above mentioned controller. And it worked. How come it doesn't work this
(second) time?)

Can anybody save my weekend? That would be so cool!

Thanks very much!
Tom
Frederick C. (Guest)
on 2008-10-18 19:34
(Received via mailing list)
On Oct 18, 11:21 am, Tom Ha <removed_email_address@domain.invalid> wrote:
> Hi there,
>
> I have this ajax problem, I'm desparately trying to debug since 1 entire
> day now:
>
What's calling the action? If you've passed an :update option to
link_to_remote (or remote_function etc...) then you must not use
render :update

Fred
Tom H. (Guest)
on 2008-10-18 19:55
Well, this is the form that calls the action (so there is no "remote_"
to the form or submit tag).



<% form_for (:cv, :url => '/user/cvs', :html => { :multipart => true })
do |f| %>
  <p>
    Upload A CV:
    <%= f.file_field :uploaded_data %>
    <%= hidden_field_tag 'applicationfile_id', @applicationfile.id %>
  </p>
  <p>
    <%= submit_tag 'Save' %>
  </p>
<% end %>



Everything gets uploaded correctly with it. But it doesn't update the
page (the DIV/partial), but instead just displays the javascript code...
Frederick C. (Guest)
on 2008-10-18 20:04
(Received via mailing list)
On Oct 18, 4:55 pm, Tom Ha <removed_email_address@domain.invalid> wrote:
> Well, this is the form that calls the action (so there is no "remote_"
> to the form or submit tag).
>
If it's just a regular post (ie not using remote_form_for) you can't
use render :update.

Fred
Sjoerd A. (Guest)
on 2008-10-19 02:02
If you need this to be Ajaxified use remote_form_for instead, also check
out: http://www.caboo.se/articles/2007/4/2/ajax-file-upload, as you're
uploading file data.
Tom H. (Guest)
on 2008-10-21 01:55
Thanks for the clarification and your hints, guys!
This topic is locked and can not be replied to.