# Page.update\_html not executed

**URL:** <https://www.ruby-forum.com/t/page-update-html-not-executed/63064>\
**Category:** Rails\
**Created:** [June 11, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064 "2006-06-11T14:13:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 11, 2006, 2:13pm UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/1 "2006-06-11T14:13:44Z")

</div>

Hi,

when doing:  
render :update do |page|  
page.replace\_html ‘suggested\_contractors’, :partial =\>  
‘contractors’  
page.visual\_effect :highlight, ‘suggested\_contractors’  
end

I got js as output, it is not executed, return html _contains_:  
try { Element.update(“suggested\_contractors”, "  
\n 12345678910\n  
\n  
"); new Effect.Highlight(“suggested\_contractors”,{}); } catch (e) {  
alert(‘RJS error:\n\n’ + e.toString());  
alert(‘Element.update(“suggested\_contractors”, "  
\n 12345678910\n  
\n  
");\nnew Effect.Highlight(“suggested\_contractors”,{});’); throw e }

Any idea?

Thank you,  
Jean-Etienne www.novAgora.hu

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 11, 2006, 8:14pm UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/2 "2006-06-11T20:14:13Z")

</div>

I’ll bet the content-type isn’t getting set correctly.

Are you setting it explicity in a filter somewhere,  
accidentally overriding the correct value?

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 12, 2006, 2:48am UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/3 "2006-06-12T02:48:18Z")

</div>

Or, you’re linking to the call with a link\_to instead of link\_to\_remote.  
Been there, lost lots of hair.

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 12, 2006, 8:34am UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/4 "2006-06-12T08:34:19Z")

</div>

oh…maybe you forgot to include

javascript\_include\_tag :defaults

in your layout

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 12, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/5 "2006-06-12T12:08:01Z")

</div>

Be sure that you don’t specify an update action twice, i.e. in an rjs  
template and a link\_to\_remote. If you have a link\_to\_remote :update =\>  
“mydiv” , AND you have page.update\_html “mydiv” … in an rjs file …  
then this will happen! I hope I recall that correctly, but go looking  
for such scenarios ,

cheers  
Martin

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 14, 2006, 10:33am UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/6 "2006-06-14T10:33:27Z")

</div>

Quote from RJS Templates for Rails:

“Don’t Use the :update Option with RJS Calls  
Never use the :update option when making remote calls to actions that  
render  
RJS templates. The :update option instructs Rails to generate an  
Ajax.Updater Prototype object instead of an Ajax.Request object. The  
Ajax.Updater updates a single DOM element with the contents of the  
HTML response. RJS templates return JavaScript to the browser, which  
must  
be evaluated to produce the desired effects.”

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 12, 2006, 5:14pm UTC](https://www.ruby-forum.com/t/page-update-html-not-executed/63064/7 "2006-06-12T17:14:38Z")

</div>

Martin G. wrote:

> Be sure that you don’t specify an update action twice, i.e. in an rjs  
> template and a link\_to\_remote. If you have a link\_to\_remote :update =\>  
> “mydiv” , AND you have page.update\_html “mydiv” … in an rjs file …  
> then this will happen! I hope I recall that correctly, but go looking  
> for such scenarios ,
> 
> cheers  
> Martin

That was the problem.

Thank you
