Forum: Ruby on Rails link_to_remote and browser compatibility

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jonas B. (Guest)
on 2005-12-15 14:15
link_to_remote generates the javascript: new Ajax.Updater(...). Have I
missed something or doesn't this handle browsers with javascript support
but without XHR support?

What I'd like to do is:
1. If the browser supports XHR, use XHR
2. If the browser supports javascript (and perhaps even if the XHR
request fails) do a POST via javascript
3. If the browser doesn't support javascript use POST via a standard
form

Is that possible?

Thanks in advance,

Jonas Bengtsson
http://andthennothing.net
Andrew F. (Guest)
on 2005-12-15 14:26
(Received via mailing list)
did you include this in your header?

<%= javascript_include_tag 'prototype',  'scriptaculous' %>

as well as have those files in your javascripts folder found in the
public directory?

there is also a url_for attribute that you can add to your
link_to_remote that will do a post if the browser does not have
javascript turned on or does not support it.

Andrew
Jonas B. (Guest)
on 2005-12-15 17:23
Thanks for your answer Andrew,

Andrew F. wrote:
> did you include this in your header?
>
> <%= javascript_include_tag 'prototype',  'scriptaculous' %>
>
> as well as have those files in your javascripts folder found in the
> public directory?

Yes. link_to_remote works when I use a browser with XHR support so
everything is set up correctly.

> there is also a url_for attribute that you can add to your
> link_to_remote that will do a post if the browser does not have
> javascript turned on or does not support it.

Do you mean options['url']? Won't it just do a GET on that url if
javascript is turned off (I want a POST)? And that still don't address
browsers without XHR support.

/Jonas
This topic is locked and can not be replied to.