mcintyre.tim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Nov-14 10:47 UTC
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
uhm i think link_remote_to degardes gracefully by default. it would create something like this: <a href="/bla/blubb" onClick="AJAX Code Goes Here">Blablabla</a> 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. .... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 => <degraded URL> in the html_options argument, it will be used. If not, the tag''s href will be set to #. --Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---