# In place editor and rjs

**URL:** <https://www.ruby-forum.com/t/in-place-editor-and-rjs/131165>\
**Category:** Rails\
**Created:** [March 6, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-rjs/131165 "2008-03-06T16:42:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keeny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@keeny](https://www.ruby-forum.com/u/keeny)\
**Post date:** [March 6, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-rjs/131165/1 "2008-03-06T16:42:55Z")

</div>

Hi all,

I’ve had a read thru similar topics on the list but am still  
confused…

I want an in place editor to call an action that does some rjs, not  
just return a text string.

Normally the action would do something like:

def edit  
# model.update(params[:value]  
render :text =\> params[:value]  
end

But I want to do more stuff:

def edit  
# model.update(params[:value]  
render :action =\> ‘edit.rjs’  
end

What options do I need to use in the view to evaluate the javascript  
returned? At the moment the javascript is just being displayed in the  
field as a string.

I have hacked together the following, but is there a cleaner ‘more  
rails’ way to do this?

\<%= in\_place\_editor @model.id, :url =\> {:action =\> ‘edit’, :id =\>  
@model.id},  
:complete =\> “function(transport, element){  
// Id rather use rjs to do my javascript than have it in the view  
like this.  
$  
(‘another\_element\_that\_i\_want\_to\_update’).update(transport.responseText);  
}” %\>

Any advice greatly appreciated,

Barry.

---

<div class="post-metadata">

**Author:** ![keeny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f19dbf/32.png) [@keeny](https://www.ruby-forum.com/u/keeny)\
**Post date:** [March 11, 2008, 3:08pm UTC](https://www.ruby-forum.com/t/in-place-editor-and-rjs/131165/2 "2008-03-11T15:08:29Z")

</div>

I’d been using an old version of the helper. I downloaded the current  
version of in\_place\_editor\_field plugin and passed the option:

\<%= in\_place\_editor\_field …, …, :script =\> true %\>

Works fine now. Cheers.
