# Ajax link\_to\_remote with toggle\_blind

**URL:** <https://www.ruby-forum.com/t/ajax-link-to-remote-with-toggle-blind/112672>\
**Category:** Rails\
**Created:** [August 22, 2007, 12:07am UTC](https://www.ruby-forum.com/t/ajax-link-to-remote-with-toggle-blind/112672 "2007-08-22T00:07:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [August 22, 2007, 12:07am UTC](https://www.ruby-forum.com/t/ajax-link-to-remote-with-toggle-blind/112672/1 "2007-08-22T00:07:00Z")

</div>

I’m having some problems with this link\_to\_remote call. What I want  
ideally is if the user needs more information they can click on the name  
and have the details show up. I want to only make the query for more  
information when they click rather than loading all the information and  
hiding it from the start (no need to send info that will never be  
displayed).

Once they click for more details they can toggle the details to show or  
hide by clicking the same name. So ideally I want the first click to go  
and get the info and then subsequent clicks to toggle the display of the  
info.

What I have now does that; it will go and get it with the link\_to\_remote  
call, but once it is finished it will blind up immediately. I basically  
want the blind to stay down with freshly retrieved data.

Below is the code:

\<%= link\_to\_remote( child.value.to\_s,  
:update =\> container,  
:url =\>{ :action =\> :add\_children},  
:with =\> withText,  
:success =\>visual\_effect(:toggle\_blind, container, :duration =\> 0.2) )%\>

Any suggestions would be greatly appreciated,  
Chris

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [August 22, 2007, 1:03am UTC](https://www.ruby-forum.com/t/ajax-link-to-remote-with-toggle-blind/112672/2 "2007-08-22T01:03:42Z")

</div>

sounds like what you want is first click requests and shows. second  
click hides the data, third click shows again.

So,

try

link\_to child.value.to\_s, ‘#’, {  
:onclick =\> “show\_hide\_with\_ajax(#{container}, #{withText})”}

---

<div class="post-metadata">

**Author:** ![chrismalek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@chrismalek](https://www.ruby-forum.com/u/chrismalek)\
**Post date:** [August 22, 2007, 5:31pm UTC](https://www.ruby-forum.com/t/ajax-link-to-remote-with-toggle-blind/112672/3 "2007-08-22T17:31:49Z")

</div>

Great thanks Keynan,

I had to modify that code a little bit, but it sure helped. Everything  
is working as it should. Except when I scroll down and click a link  
further down the page, it will pop me back up to the top of the page.  
The action happened as it should, but I need to scroll back down to  
where I was. Kind of annoying.

Any suggestions?
