# Render :update / page.replace\_html problem

**URL:** <https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220>\
**Category:** Rails\
**Created:** [October 18, 2008, 12:21pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220 "2008-10-18T12:21:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 18, 2008, 12:21pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/1 "2008-10-18T12:21:41Z")

</div>

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:

[…]

[...]
# 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

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 18, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/2 "2008-10-18T17:34:05Z")

</div>

On Oct 18, 11:21 am, Tom Ha [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 18, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/3 "2008-10-18T18:04:34Z")

</div>

On Oct 18, 4:55 pm, Tom Ha [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 18, 2008, 5:55pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/4 "2008-10-18T17:55:16Z")

</div>

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| %\>

Upload A CV: \<%= f.file\_field :uploaded\_data %\> \<%= hidden\_field\_tag 'applicationfile\_id', @applicationfile.id %\>

\<%= submit\_tag 'Save' %\>

\<% end %\>

Everything gets uploaded correctly with it. But it doesn’t update the  
page (the DIV/partial), but instead just displays the javascript code…

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 19, 2008, 12:02am UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/5 "2008-10-19T00:02:41Z")

</div>

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](http://www.caboo.se/articles/2007/4/2/ajax-file-upload), as you’re  
uploading file data.

---

<div class="post-metadata">

**Author:** ![tharrisx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e19adc/32.png) [@tharrisx](https://www.ruby-forum.com/u/tharrisx)\
**Post date:** [October 20, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/render-update-page-replace-html-problem/151220/6 "2008-10-20T23:55:05Z")

</div>

Thanks for the clarification and your hints, guys!
