Michael Wong
2009-Apr-19 15:43 UTC
link_to_remote clicking a link should replace that link
Hi, I haven''t touched Ruby for a while. How do you replace link_to_remote text after user clicks on them? Once a user clicks ''Delete this post,'' I want the text gets replaced to ''pending request'' -- is there any easy way to do this? <%= link_to_remote(''Delete this post'', :complete => ''pending request'', :url => { :controller => "posts", :action => "delete",:id => "delete_link" + post_item.id.to_s, :post_id => post_item.id})%> -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-19 15:53 UTC
Re: link_to_remote clicking a link should replace that link
On Apr 19, 4:43 pm, Michael Wong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I haven''t touched Ruby for a while. How do you replace link_to_remote > text after user clicks on them? Once a user clicks ''Delete this post,'' > I want the text gets replaced to ''pending request'' -- is there any easy > way to do this?You''ll need a smidgen of javascript for this. if blah where the dom id of the link, $(''blah'').update ''pending request'' might be enough or you might want to actually replace the link rather than just change it''s text. The prototype api ( http://prototypejs.org/api ) has details on both (obviously if you''re using a different js library, read that api). Depending on your app you might want to do with when the request is started rather than when the request completes; one of the other options like :before might be appropriate. Fred> > <%= link_to_remote(''Delete this post'', :complete => ''pending request'', > :url => { :controller => "posts", > :action => "delete",:id => "delete_link" + post_item.id.to_s, > :post_id => post_item.id})%> > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---