# How to apply an effect to a link\_to\_remote :update without u

**URL:** <https://www.ruby-forum.com/t/how-to-apply-an-effect-to-a-link-to-remote-update-without-u/54697>\
**Category:** Rails\
**Created:** [March 13, 2006, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-apply-an-effect-to-a-link-to-remote-update-without-u/54697 "2006-03-13T12:19:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_McCafferty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@Patrick\_McCafferty](https://www.ruby-forum.com/u/Patrick_McCafferty)\
**Post date:** [March 13, 2006, 12:19pm UTC](https://www.ruby-forum.com/t/how-to-apply-an-effect-to-a-link-to-remote-update-without-u/54697/1 "2006-03-13T12:19:32Z")

</div>

Hey all,

I’ve been trying to apply a slide-down (or highlight) effect to a “New  
card” link on my application. Because the item is _new_ and I’m simply  
updating it at the top, I can’t know what the div id is before I make  
the request. link\_to\_remote :complete =\> visual\_effect(:slidedown)  
doesn’t do what I want it to do. My current solution is:

\<%= link\_to\_remote ‘New card’,  
:url =\> { :action =\> ‘new\_card’, :id =\> @stack.id },  
:complete =\> evaluate\_remote\_response %\>

and then new\_card returns JS:

new Insertion.Top(‘cards’,  
‘\<%= escape\_javascript(render(:partial =\> “editcard”, :locals =\> {  
:editcard =\> @card }))%\>’);  
new Effect.SlideDown(‘card\<%= @card.id %\>’);

but this just feels horribly, horribly wrong, because I can NOT be the  
only person to ever need to do this. I know for sure that 37signals  
had to do it, for that matter.

What I want to do is:

\<%= link\_to\_remote ‘New card’,  
:url =\> { :action =\> ‘new\_card’, :id =\> @stack.id },  
:update =\> ‘cards’, :position =\> :top,  
:complete =\> visual\_effect(:slidedown) %\>

and then just render the partial in the controller. But this doesn’t  
give me good results.

Am I just stuck returning JS this way? It seems awkward.

Thanks,

Patrick

---

<div class="post-metadata">

**Author:** ![Patrick\_McCafferty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@Patrick\_McCafferty](https://www.ruby-forum.com/u/Patrick_McCafferty)\
**Post date:** [March 13, 2006, 12:31pm UTC](https://www.ruby-forum.com/t/how-to-apply-an-effect-to-a-link-to-remote-update-without-u/54697/2 "2006-03-13T12:31:41Z")

</div>

Using RJS will make it cleaner:

View:

\<%= link\_to\_remote ‘New card’, :url =\> { :action =\> ‘new\_card’, :id =\> @  
stack.id } %\>

new\_card.rjs:

page.insert\_html :top, ‘cards’, :partial =\> ‘editcard’, :object =\> @card  
page.visual\_effect :slide\_down, “card#{@card.id}”

That should do what you’re after. To use RJS you need to be using edge  
rails, or the plugin which is around somewhere. Just google for it.  
-Jonathan.

---

<div class="post-metadata">

**Author:** ![Patrick\_McCafferty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@Patrick\_McCafferty](https://www.ruby-forum.com/u/Patrick_McCafferty)\
**Post date:** [March 13, 2006, 10:27pm UTC](https://www.ruby-forum.com/t/how-to-apply-an-effect-to-a-link-to-remote-update-without-u/54697/3 "2006-03-13T22:27:14Z")

</div>

Ah, I see, and I found the plugin as well 🙂

That does make it a lot cleaner. Thanks. Luckily TxD has edge rails on  
it, or I can just keep using 1.0 🙂
