RJS and Action Renders but page doesn't update

All,

I am trying to perform a simple ajax task and am having some
difficulties with the page showing the response. The action performs,
but no response on the page.

I have found examples on the web and I believe I have copied and
pasted exactly what works from the demo site. However, on my system it
isn’t finishing. For a simple test, I have limited it down to an alert.

<%= link_to_remote ‘Doing a JavaScript alert’,
:url => {:action => ‘do_alert’} %>

Leaving out the rest of the code (controller, etc…) because it is
irrelevant. If I modify the above to this:

<%= link_to_remote ‘Doing a JavaScript alert’,
:url => {:action => ‘do_alert’}, :complete =>
“eval(request.responseText)” %>

It works. As such, I know the response is coming back but for some
reason the page doesn’t display my results. From what I understand, the
:complete should not be required.

Further, I don’t want to do an alert - I want to change some text and
show an image while an action is in progress, then remove the image when
the action is completed. I am only doing the alert as something simple
until I figure out why the page isn’t refreshing properly. Any pointers
on what I am doing wrong?

Thank you,

Michael

Michael wrote:

It works. As such, I know the response is coming back but for some


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

It would be really helpful if you could paste your rjs and the relevant
part of the controller.
If you are using Firefox then I recommend that you get Firebug and check
out the actual request and response that your link is causing.

Matthew M.
blog.mattmargolis.net

Matthew M. wrote:

Michael wrote:

It works. As such, I know the response is coming back but for some


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

It would be really helpful if you could paste your rjs and the relevant
part of the controller.
If you are using Firefox then I recommend that you get Firebug and check
out the actual request and response that your link is causing.

Matthew M.
blog.mattmargolis.net

Hi Matthew,

do_alert.rjs:

page.alert “This is a test alert!!!”

Controller:

def do_alert

end

That’s pretty basic, huh? I have tried a few different examples with no
luck. I’m sure I’m missing something basic!

Your help is appreciated.

Michael

On Monday, July 17, 2006, at 12:32 AM, Michael wrote:

It would be really helpful if you could paste your rjs and the relevant

http://lists.rubyonrails.org/mailman/listinfo/rails
I presume you are including the appropriate javascript files in your
layout.

_Kevin
www.sciwerks.com

Michael wrote:

Kevin O. wrote:

On Monday, July 17, 2006, at 12:32 AM, Michael wrote:

It would be really helpful if you could paste your rjs and the relevant

http://lists.rubyonrails.org/mailman/listinfo/rails
I presume you are including the appropriate javascript files in your
layout.

_Kevin
www.sciwerks.com

Kevin,

Yes - I have the javascripts included as per
<%= javascript_include_tag :defaults %>

Remember, the :complete => “eval(request.responseText)” statement allows
me to see the returned code.

Thank you…

Michael

Okay - Now I am limiting this to just one question! I have changed from
the “alert” test to something more along the lines of what I want. I’m
updating a div with something and adding a visual effect. I spent the
10 bucks and bought Cody F.'s eBook titled “RJS Templates for Rails”
and cut and paste the very first sample. It did not work, as suspected.
I simply added the ":complete => “eval…” and it worked fine. So I
guess my only question is why am I having to put the :complete…
portion in my code when it doesn’t appear that other samples, including
Cody’s, require that?

Thanks,

Michael

Michael wrote:

I presume you are including the appropriate javascript files in your
Remember, the :complete => “eval(request.responseText)” statement allows
the “alert” test to something more along the lines of what I want. I’m

Michael

What version of Rails are you running? Have you tried using inline rjs
in your controller? If you can get Firefox and Firebug and post the
XMLHTTPrequest and response for us that would be great.

Matthew M.
blog.mattmargolis.net

Matthew M. wrote:

Michael wrote:

I presume you are including the appropriate javascript files in your
Remember, the :complete => “eval(request.responseText)” statement allows
the “alert” test to something more along the lines of what I want. I’m

Michael

What version of Rails are you running? Have you tried using inline rjs
in your controller? If you can get Firefox and Firebug and post the
XMLHTTPrequest and response for us that would be great.

Matthew M.
blog.mattmargolis.net

Hi Matthew,

I’m on Rails 1.1.2. I did try inline RJS as well with same results. To
date, I haven’t used Firebug but I will install it sometime this week
and play around with it to see what is going on. For now, I have
working what I need and actually ended up needing to put in the
:complete anyway (along with :loading) in order to set the progress
indicator properly and hide it upon completion.

Cody’s eBook on RJS Templates had an example of exactly what I was
trying to do, so it was worth the $10.00. I have a long running action
(pdf file creation that gets emailed to a user) and simply wanted to
allow the user to do this via an ajax call so they could get a visible
clue that they not only clicked the button but that it was doing
something in the background.

I’m beginning to think that the :complete must be a default setting that
isn’t being set in my application. It was mostly frustrating to me
because I was using examples found on the web w/o this setting and
couldn’t get anything to work (actually, to display the updated values).
I guess for me it is more of a “why didn’t it work” question.

Having worked with XMLHTTPRequests many years ago via Javascript and
MSXMLHTTP, I can say that I LOVE the RJS functionality. It is so clean
and once you figure out how to use it - it is very cool.

Regards,

Michael

Kevin O. wrote:

On Monday, July 17, 2006, at 12:32 AM, Michael wrote:

It would be really helpful if you could paste your rjs and the relevant

http://lists.rubyonrails.org/mailman/listinfo/rails
I presume you are including the appropriate javascript files in your
layout.

_Kevin
www.sciwerks.com

Kevin,

Yes - I have the javascripts included as per
<%= javascript_include_tag :defaults %>

Remember, the :complete => “eval(request.responseText)” statement allows
me to see the returned code.

Thank you…

Michael

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