# RJS Doesn't work for me :(

**URL:** <https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152>\
**Category:** Rails\
**Created:** [September 27, 2006, 4:36am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152 "2006-09-27T04:36:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [September 27, 2006, 4:36am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152/1 "2006-09-27T04:36:32Z")

</div>

I’m developing on my Mac OS X Powerbook using just Mongrel. I’ve been  
trying to get the simplest of RJS to work:

# view

ruby

link\_to\_remote ‘update’, :url=\>{:action=\>:doit}

# controller

def doit  
render :update do |page|  
page.replace\_html(‘test’, ‘rails’)  
# page[‘test’].replace\_html(‘rails’) # doesn’t work either  
# page[‘test’].value = ‘rails’ # doesn’t work either  
# page.hide ‘test’ # doesn’t work either  
# bunch of other RJS attempts that don’t work…  
end  
end

Am I missing something? The link appears to work, as clicking it shows  
up in the log. I have no idea why it’s not working, unless maybe it’s a  
Mongrel-only thing (as opposed to using Mongrel and Lighty) – but  
that’s a shot in the dark. Or maybe it’s related to using controller  
modules? If I add “:update=\>‘test’” to the link tag, the div gets  
changed to “Element.update(“test”, “rails”);” or  
“$(‘test’).value=‘rails’” or whatever. I’ve restarted Mongrel many  
times, tried it in Safari, refreshed, checked my javascript settings (it  
does seem like the javascript isn’t getting run for some reason), etc.  
– all to no avail. Anybody have ANY idea what the problem might be? I’m  
getting cross-eyed…

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [September 27, 2006, 5:05am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152/2 "2006-09-27T05:05:58Z")

</div>

Joe R. MUDCRAP-CE wrote:

> # controller
> 
> getting cross-eyed…
> 
> Thanks,  
> Joe
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Sounds like you forgot to put…

\<%= javascript\_include\_tag :defaults %\>

in the head of your layout file.

\_Kevin

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [September 27, 2006, 5:45am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152/3 "2006-09-27T05:45:05Z")

</div>

\_Kevin wrote:

> Sounds like you forgot to put…
> 
> \<%= javascript\_include\_tag :defaults %\>
> 
> in the head of your layout file.

Nope, it’s there (link\_to\_remote wouldn’t work otherwise, if I’m not  
mistaken).

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [September 27, 2006, 6:04am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152/4 "2006-09-27T06:04:03Z")

</div>

I’d get a copy of the firebug extension for firefox and see what the  
AJAX request/response looks like.

\_Kevin

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [September 27, 2006, 6:34am UTC](https://www.ruby-forum.com/t/rjs-doesnt-work-for-me/70152/5 "2006-09-27T06:34:46Z")

</div>

\_Kevin wrote:

> I’d get a copy of the firebug extension for firefox and see what the  
> AJAX request/response looks like.
> 
> \_Kevin

I wasn’t aware of that extension – might come in handy in the future.  
🙂

I tried one other thing I hadn’t thought of – ‘rake  
rails:update:javascripts’ – and now RJS works! I installed Rails on  
this computer not too long ago (certainly after 1.1) – you’d think the  
javascripts would be up to date. Wonder what the deal was…

Joe
