# RJS Problem..Now Whats incrorect here

**URL:** <https://www.ruby-forum.com/t/rjs-problem-now-whats-incrorect-here/143345>\
**Category:** Rails\
**Created:** [July 17, 2008, 3:56pm UTC](https://www.ruby-forum.com/t/rjs-problem-now-whats-incrorect-here/143345 "2008-07-17T15:56:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [July 17, 2008, 3:56pm UTC](https://www.ruby-forum.com/t/rjs-problem-now-whats-incrorect-here/143345/1 "2008-07-17T15:56:30Z")

</div>

I am trying to Update a field on my search result page through  
in\_place\_edit and then render a partial to display the updated contents.  
I am receving the following instead of the real value which is “John  
Wright”

try { Element.update(“first\_name”, "\n \u003Cspan  
class=“in\_place\_editor\_field”  
id=“copy\_first\_name\_10115\_in\_place\_editor”\u003EJohn  
Wright\u003C/span\u003E\u003Cscript type=“text/javascript”\

P.S. If i refresh the page manually i get the correct Values as updated  
on the page.

Following is my the code for the 4 files required to implement

1. The list of search results (view)
2. The controller contating the definition updateattribute
3. The updateattribute.rjs
4. \_first\_name.html.erb partial

# part of view showing search results

\<%if params[:first\_name]=“1”%\>

\<%end%\>

.  
.  
.

\<%end%\>

| \<%unless  
person.first\_name.blank?%\>  
\<%=@copyofperson = person; in\_place\_editor\_field :copyofperson,  
:first\_name, {}, :url =\> { :controller =\> ‘person’, :action =\>  
‘updateattribute’, :id =\> person.id } %\>  
\<%end%\> |

#person controller  
def updateattribute  
@person = Person.find(params[:id])  
i = params[:editorId]  
j = i.split("_")  
j.pop  
j.pop  
j.pop  
j.pop  
j.delete\_at(0)  
field\_name = j.join("_")#Getting the field to be updated in field\_name

@person.update\_attribute “#{field\_name}”, “#{params[:value]}”

end

# updateattribute.rjs

page.replace\_html ‘first\_name’, :partial=\>‘first\_name’, :object=\>@person

# \_first\_name.html.erb

\<%=@copyofperson = @person; in\_place\_editor\_field :copyofperson, :first\_name, {}, :url =\> { :controller =\> 'person', :action =\> 'updateattribute', :id =\> @person.id } %\>

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [July 17, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/rjs-problem-now-whats-incrorect-here/143345/2 "2008-07-17T17:28:22Z")

</div>

On 17 Jul 2008, at 14:56, Ank Ag wrote:

> Wright\u003C/span\u003E\u003Cscript type=“text/javascript”\

If I remember correctly, the in place editor is expecting you to  
return an html fragment it can stick in the DOM, whereas you’re  
sticking in some JS.  
There may be some options for customizing that, but I can’t remember  
off the top of my head.

Fred

---

<div class="post-metadata">

**Author:** ![ankit2584](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/51bf81/32.png) [@ankit2584](https://www.ruby-forum.com/u/ankit2584)\
**Post date:** [July 17, 2008, 8:38pm UTC](https://www.ruby-forum.com/t/rjs-problem-now-whats-incrorect-here/143345/3 "2008-07-17T20:38:10Z")

</div>

Frederick C. wrote:

> On 17 Jul 2008, at 14:56, Ank Ag wrote:
> 
> > Wright\u003C/span\u003E\u003Cscript type=“text/javascript”\
> 
> If I remember correctly, the in place editor is expecting you to  
> return an html fragment it can stick in the DOM, whereas you’re  
> sticking in some JS.  
> There may be some options for customizing that, but I can’t remember  
> off the top of my head.
> 
> Fred

Could you please tell me what should i look for on the internet. Or any  
other alternative to implement in place edit  
Thanks
