# Render :update vs. render :partial -\> need :update help

**URL:** <https://www.ruby-forum.com/t/render-update-vs-render-partial-need-update-help/139641>\
**Category:** Rails\
**Created:** [June 5, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/render-update-vs-render-partial-need-update-help/139641 "2008-06-05T18:36:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djconcepcion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@djconcepcion](https://www.ruby-forum.com/u/djconcepcion)\
**Post date:** [June 5, 2008, 6:36pm UTC](https://www.ruby-forum.com/t/render-update-vs-render-partial-need-update-help/139641/1 "2008-06-05T18:36:00Z")

</div>

I am trying to make a render :update work, and couldn’t find anything on  
the forums or in books on what I am doing wrong:

def index  
render :update do |page|  
page.replace\_html ‘asection’, :text =\> ‘99’ (or :partial =\>  
‘somepartial’ etc.)  
end  
end

this never works. Instead, the javascript is rendered on the page -  
perhaps because it failed? -  
instead of the result of the execution itself. Once, an alert was  
actually popped up (so it did execute in one case, but failed). In most  
cases, nothing happens other than the replacement of the element by the  
javascript code, which looks something like:

try { Element.update(“asection”, “99\n”); } catch (e) { alert(‘RJS  
error:\n\n’ + e.toString()); alert(‘Element.update(“asection”,  
“99\n”);’); throw e }

replacing

 replace me

the following always works, I don’t have a problem with basic partials:

def index  
render :partial =\> ‘somepartial’  
end

in both cases, the controller is called from a  
periodically\_call\_remote  
statement

What am I doing wrong? Thanks in advance for any assistance.

---

<div class="post-metadata">

**Author:** ![djconcepcion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@djconcepcion](https://www.ruby-forum.com/u/djconcepcion)\
**Post date:** [June 5, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/render-update-vs-render-partial-need-update-help/139641/2 "2008-06-05T18:40:09Z")

</div>

On 5 Jun 2008, at 17:36, DJ Cole wrote:

> the following always works, I don’t have a problem with basic  
> partials:
> 
> def index  
> render :partial =\> ‘somepartial’  
> end
> 
> in both cases, the controller is called from a  
> periodically\_call\_remote  
> statement

Are you passing :update to periodically\_call\_remote? If so, don’t  
(that tells prototype that you’ll be giving it a chunk of data to  
insert rather than some js to execute.

Fred

---

<div class="post-metadata">

**Author:** ![djconcepcion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/57b2e6/32.png) [@djconcepcion](https://www.ruby-forum.com/u/djconcepcion)\
**Post date:** [June 5, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/render-update-vs-render-partial-need-update-help/139641/3 "2008-06-05T18:40:55Z")

</div>

Most likely you’re using th :update option of periodically\_call\_remote

In this case it expects pure html as response and will treat your js as  
such  
Just kkep out the :update, your page.replace tells the browser what to  
replace anyway
