RJS Doesn't work for me :(

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

Joe R. MUDCRAP-CE wrote:

controller

getting cross-eyed…

Thanks,
Joe


Posted via http://www.ruby-forum.com/.

Sounds like you forgot to put…

<%= javascript_include_tag :defaults %>

in the head of your layout file.

_Kevin

_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

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

_Kevin

_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.
:slight_smile:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs