# RJS doesn't work

**URL:** <https://www.ruby-forum.com/t/rjs-doesnt-work/117449>\
**Category:** Rails\
**Created:** [October 17, 2007, 12:26am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work/117449 "2007-10-17T00:26:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a698b9/32.png) [@juan](https://www.ruby-forum.com/u/juan)\
**Post date:** [October 17, 2007, 12:26am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work/117449/1 "2007-10-17T00:26:15Z")

</div>

Hi,

When using an :update in a remote function it does work without  
problems. Removing it and adding instead a .rjs file to modify a part of  
the HTML doesn’t work.

This is what receives the browser:

Element.update(“content\_pane”, “— TEST-CONTENT —”)

But it just ignores it. There is no error in the javascript console. The  
tag used is:

\<%= collection\_select “user”, “id”, @users, “id”, “firstname”,  
{ },  
{ :id =\> “selectUserList”,  
:class =\> “width100”,  
:onchange =\> remote\_function( :with =\> “‘id=’ + value”,  
:url =\> { :action =\> :select\_user } ) } %\>

As said, if I just use the :update =\> “content\_pane” approach, it does  
work without problems.

Do you know what can be wrong ?

Thanks in advance. Any comment would be really welcome, I’m a bit lost  
here…

---

<div class="post-metadata">

**Author:** ![juan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a698b9/32.png) [@juan](https://www.ruby-forum.com/u/juan)\
**Post date:** [October 17, 2007, 9:21am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work/117449/2 "2007-10-17T09:21:42Z")

</div>

Well, I continue fighting against this issue. As far as I can tell from  
everything I’ve googled, you can’t use remote\_function with a RJS due to  
the JS implementation. A link\_to\_remote will do (I’ll try that this  
night at home)

Anyway, I’d need to use it in a collection\_select context, where the  
onchange event must run a RJS template, so the link\_to\_remote doesn’t  
seem to be the best idea.

Do you know if is there any alternative to run RJS templates to be used  
with events ?

---

<div class="post-metadata">

**Author:** ![juan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a698b9/32.png) [@juan](https://www.ruby-forum.com/u/juan)\
**Post date:** [October 17, 2007, 11:30pm UTC](https://www.ruby-forum.com/t/rjs-doesnt-work/117449/3 "2007-10-17T23:30:53Z")

</div>

Sorry, the problem is rforum. I’ve “installed” rforum 0.2 and since then  
it fails.

The RJS file is executed, the JS sent to the browser but without  
success…

Does anyone have any clue about how to solve this ?

Best regards,  
Juan

---

<div class="post-metadata">

**Author:** ![juan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/a698b9/32.png) [@juan](https://www.ruby-forum.com/u/juan)\
**Post date:** [October 17, 2007, 3:30pm UTC](https://www.ruby-forum.com/t/rjs-doesnt-work/117449/4 "2007-10-17T15:30:55Z")

</div>

\<%= collection\_select “user”, “id”, @users, “id”, “firstname”,  
{ },  
{ :id =\> “selectUserList”, :class =\> “width100” } %\>

\<%= observer\_field ‘selectUserList’, :url =\> { :action  
=\> :select\_user } %\>

This will automatically submit to the given URL and pass the selects  
value in parasm[:user][:id]  
and it works with RJS from what i know an experienced.

In fact i wonder why remote\_function doesn’t, as the API states it can  
have the same options as link\_to\_remote, which sounds like “you can  
leave out :udpate and use RJS”  
… might have a look at it’s source to see what’s the reason.

On 17 Okt., 09:21, “Juan Medín” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
