# In\_place\_edit ends up with try catch block as content?

**URL:** <https://www.ruby-forum.com/t/in-place-edit-ends-up-with-try-catch-block-as-content/93192>\
**Category:** Rails\
**Created:** [April 28, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/in-place-edit-ends-up-with-try-catch-block-as-content/93192 "2007-04-28T23:58:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [April 28, 2007, 11:58pm UTC](https://www.ruby-forum.com/t/in-place-edit-ends-up-with-try-catch-block-as-content/93192/1 "2007-04-28T23:58:10Z")

</div>

I have a few in place edit fields in a table. but when i enter a null  
value it now, promts me with the alert. ~BUT then enters the returned  
rjs into the editable field: ~??

try {ry { alert(“not working”); } catch (e) { alert(‘RJS error:\n\n’ +  
e.toString()); alert(‘alert(“not working”);’); throw e }

* * *

rhtml:

"\>\<%= track.title %\> \<% if @edit %\> " class="small\_edit"\>edit \<%= in\_place\_editor "#{dom\_id(track)}\_title", {:url =\> url\_for(:action =\> "set\_track\_title", :id=\> track), :class =\> 'editor', :external\_control =\> "#{dom\_id(track)}\_title\_edit"} %\> \<% end %\> 
* * *

Which call this method:

def set\_track\_title  
@track = Track.find(params[:id])  
@track.title = params[:value]  
@message = “\n Title #{@track.errors[‘title’]}” unless @track.save

```
render :action => 'update_track.rjs'

```

end

=-----------------  
Which calls this rjs template

page.alert ‘why wont you work…damn you rjs error!!’

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [April 29, 2007, 1:20am UTC](https://www.ruby-forum.com/t/in-place-edit-ends-up-with-try-catch-block-as-content/93192/2 "2007-04-29T01:20:59Z")

</div>

Most times whenever you see javascript being displayed from your rjs  
template it’s  
more often than not because you’re also using the :update option on  
the AJAX call.  
I haven’t looked at what the in place editor creates but I’d be  
willing to bet that it’s using  
:update by default so if you want to use rjs you’ll have to create  
your own action to do  
the update.

Hope that helps,

-Michael  
[http://javathehutt.blogspot.com](http://javathehutt.blogspot.com)

---

<div class="post-metadata">

**Author:** ![adam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@adam](https://www.ruby-forum.com/u/adam)\
**Post date:** [April 29, 2007, 11:44am UTC](https://www.ruby-forum.com/t/in-place-edit-ends-up-with-try-catch-block-as-content/93192/3 "2007-04-29T11:44:57Z")

</div>

Michael K. wrote:

> Most times whenever you see javascript being displayed from your rjs  
> template it’s  
> more often than not because you’re also using the :update option on  
> the AJAX call.  
> I haven’t looked at what the in place editor creates but I’d be  
> willing to bet that it’s using  
> :update by default so if you want to use rjs you’ll have to create  
> your own action to do  
> the update.
> 
> Hope that helps,
> 
> -Michael  
> [http://javathehutt.blogspot.com](http://javathehutt.blogspot.com)

Thanks for the reply.

The default method called from an in\_place\_edit field is

set\_track\_

So in my case its: set\_track\_title. I have added a few puts in there to  
check that it get the params[:id] value and it seems to be fine.

One thing to note, while the logs and above puts suggest that i am  
sending and receiving the params[:id]. When i view the action in firebug  
the posted value is ‘value=’???
