Forum: Ruby on Rails link_to_remote clicking a link should replace that link

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.
3945175561ce50958dd5b11fc68aaf39?d=identicon&s=25 Michael Wong (mwong)
on 2009-04-19 17:43
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})%>
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-19 17:54
(Received via mailing list)
On Apr 19, 4:43 pm, Michael Wong <rails-mailing-l...@andreas-s.net>
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
This topic is locked and can not be replied to.