Degradable ajax links

hey all

I know you can use form_remote_tag to help create degradable form tags
but what about links? Seems it may be doable, not sure actually, with
some combination of a regular anchor element and a remote_function call
but I would be surprised if there wasn’t a more idiometric aproach?

Am I missing something obvious!

Thanks in advance!
Tim

uhm i think link_remote_to degardes gracefully by default.

it would create something like this:

Blablabla

The onclick event does the ajax call and stops the default behaviour
(requesting the page pointed at by href=“”). If Javascript is disabled,
the normal href=“” target is requested as the behaviour is not stopped
by JavaScript…

could be wrong though, didnt do much ajax yet and not at my machine at
the moment. …

link_to_remote doesn’t: it sets the href to “#”

You should check out the Unobstructive Javascript (UJS) plugin
(http://www.ujs4rails.com/) it has helpers that do this kind of thing
properly (and more). The guys behind it also gave a nice presentation
about it at railsconf europe, you can grab the slides from their
presentation off the same website

Fred

On Tue, Nov 14, 2006 at 03:41:40AM -0800, Thorsten L wrote:
} uhm i think link_remote_to degardes gracefully by default.
[…]

Not by default, but it can be told to. The method signature is:

  def link_to_remote(name, options = {}, html_options = {})

If you include :href => in the html_options argument, it
will be used. If not, the tag’s href will be set to #.

–Greg