# Need help on rjs calls and partials

**URL:** <https://www.ruby-forum.com/t/need-help-on-rjs-calls-and-partials/157001>\
**Category:** Rails\
**Created:** [January 6, 2009, 11:31am UTC](https://www.ruby-forum.com/t/need-help-on-rjs-calls-and-partials/157001 "2009-01-06T11:31:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa125](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@sa125](https://www.ruby-forum.com/u/sa125)\
**Post date:** [January 6, 2009, 11:31am UTC](https://www.ruby-forum.com/t/need-help-on-rjs-calls-and-partials/157001/1 "2009-01-06T11:31:38Z")

</div>

Hey all -

## What I’m trying to accomplish is creating my own edit in place on a set of data. Right now I’m just toying with some nonsense app, but when I figure it out it’ll be put to good use. I divide my code between the view, the partial, the controller and the rjs template. For the sake of example, I have a list of products and I’m trying to enable editing their names:

```
# in the view

```

# Product List
 \<%= render :partial =\> 'product', :collection =\> @products, :locals =\> {:edit\_mode =\> false }}%\> 

 \<%= link\_to\_function 'edit', go\_to\_edit\_mode %\>
# in the partial

\<% @product = product %\>

 \<% if edit\_mode -%\> \<%= text\_field :product, :name, :size =\> 10 %\> \<% else -%\> \<%= product.name %\> \<% end -%\> 

#in the controller (\_product.html.erb)  
def go\_to\_edit\_mode  
@prods = Product.find(:all)  
respond\_to do |format|  
format.html { render :partial =\> ‘product’,  
:collection =\> @prods,  
:locals =\> {:edit\_mode =\> false }}  
format.js  
end  
end

# in the rjs (go\_to\_edit\_mode.js.rjs)

## page.replace\_html ‘prod-table’, :partial =\> ‘product’, :collection =\> Product.find(:all, :order =\> ‘name’), :edit\_mode =\> true

This is hardly working, though I think I’m going in the right  
direction… Someone whos a seasoned rails developer will probably see  
the problems right away, but since I’m new, I’d very much appreciate any  
help I could get here - thanks.
