Determing JS+AJAX vs. button

I’d like to use on browsers supporting AJAX link_to_remote or
button_to_function/remote_function and on rest button_to and link_to.

How can I determine it?

I’ve probably left my head… somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)

Maciej P. wrote:

I’d like to use on browsers supporting AJAX link_to_remote or
button_to_function/remote_function and on rest button_to and link_to.

How can I determine it?

Send both systems, and let the browser figure it out, like this:

<%= my manual buttons %>

<%= javascript_tag … %>

A browser without JavaScript will render the HTML inside , so
put
your buttons there. And only a browser with JavaScript will respect
the

tags that javascript_tag inserts, so I suspect you could put 'document.write' calls in there that insert your link_to_remote tags. /Pragmatic Ajax/ has a great section on degradability, but I don't know if it has the trick. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax

On Fri, 11 May 2007 18:16:32 -0700, Phlip wrote:

<%= my manual buttons %>

/Pragmatic Ajax/ has a great section on degradability, but I don’t know
if it has the trick.

Thank you - sometimes I forget about those base (x)html tricks…

Regards

I’ve probably left my head… somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)

Maciej,

I’d like to use on browsers supporting AJAX link_to_remote or
button_to_function/remote_function and on rest button_to and
link_to.

link_to_remote offers fallback for js-challenged browsers, so this
code would do what you need :(untested)

<%= link_to_remote “Delete”,
{:url => {:action => “delete”, :id => id} }, ## ← if JS
available
{:href => url_for(:action => “delete”,:id => id)} ## ← if NO JS
%>

, and in the controller you’d use ‘respond_to’ to handle both calls
within one action.

Alain R.

blog.ravet.com/

On Sat, 12 May 2007 12:33:56 +0200, Alain R. wrote:

{:url   => {:action => "delete", :id => id} },      ## <-- if JS

Alain R.
Thanks. That is just what I wanted.

Regards


I’ve probably left my head… somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)