# Link\_to\_remote clicking a link should replace that link

**URL:** <https://www.ruby-forum.com/t/link-to-remote-clicking-a-link-should-replace-that-link/165909>\
**Category:** Rails\
**Created:** [April 19, 2009, 5:43pm UTC](https://www.ruby-forum.com/t/link-to-remote-clicking-a-link-should-replace-that-link/165909 "2009-04-19T17:43:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [April 19, 2009, 5:43pm UTC](https://www.ruby-forum.com/t/link-to-remote-clicking-a-link-should-replace-that-link/165909/1 "2009-04-19T17:43:31Z")

</div>

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})%\>

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [April 19, 2009, 5:54pm UTC](https://www.ruby-forum.com/t/link-to-remote-clicking-a-link-should-replace-that-link/165909/2 "2009-04-19T17:54:43Z")

</div>

On Apr 19, 4:43 pm, Michael W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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 ( [Prototype API Documentation | Home (Deprecated URL)](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
