# Using ajax effects properly

**URL:** <https://www.ruby-forum.com/t/using-ajax-effects-properly/148740>\
**Category:** Rails\
**Created:** [September 16, 2008, 7:02pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740 "2008-09-16T19:02:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [September 16, 2008, 7:02pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740/1 "2008-09-16T19:02:01Z")

</div>

I’ve done a few ajax sites but I’ve never managed to get effects to work  
properly so I’ve decided to ask here.

I’ve got a div, which on load, contains a title and a ‘View’ link. When  
the link is clicked, the div’s content is replaced by a table with more  
info.

How do I go about putting effects in so it does something like this:

- Click the link
- Div slides up so it’s invisible
- The action returns the new div content
- Div slides back down to the new height with the new content

And the reverse for when the user clicks the ‘Hide’ link that is added.

I was using visual\_effect(:slide\_up, ‘myDiv’) but that made the div  
disappear after it slid back down again.

Can someone with knowledge of effects clue me in please?

Thanks

Matt

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [September 16, 2008, 7:36pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740/2 "2008-09-16T19:36:07Z")

</div>

search for the jrails libraries, they contain jquery it has very simple  
methods to do what you need.

/script/plugin install  
[http://ennerchi.googlecode.com/svn/trunk/plugins/jrails](http://ennerchi.googlecode.com/svn/trunk/plugins/jrails)

Once you have that installed yo do

SlideUp

that is to slide up  
to slide down

SlideDown

ve done a few ajax sites but I’ve never managed to get effects to work

> - The action returns the new div content
> 
> Matt
> 
> >

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [September 16, 2008, 8:13pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740/3 "2008-09-16T20:13:50Z")

</div>

Felipe V. wrote:

> that is to slide up  
> to slide down
> 
> SlideDown

Hi, thanks for the reply.

I can see that this looks easier, but is it actually going to work like  
link\_to\_remote? I mean will it be able to call an action and return the  
content that the action renders?

I’m not sure but I think I should be looking at combination effects or  
something.

The actual content replacement and everything works fine, but it doesn’t  
have any effects, it’s just a sharp, quick “change” which isn’t easy on  
the eye. I just want to add a slide effect to the update.

Thanks

Matt

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [September 17, 2008, 5:11pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740/4 "2008-09-17T17:11:54Z")

</div>

I’m nearly there, the problem is that :slide\_up automatically sets the  
element to hidden when in fact I want it to stay visible.

I have looked everywhere for a solution but this has really stumped me,  
how can I stop the element getting hidden between the up and down  
slides?

Thanks

Matt

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [September 17, 2008, 3:11pm UTC](https://www.ruby-forum.com/t/using-ajax-effects-properly/148740/5 "2008-09-17T15:11:35Z")

</div>

Check out this snippet

[http://snippets.dzone.com/posts/show/3206](http://snippets.dzone.com/posts/show/3206)

On Sep 16, 1:12 pm, Matt H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
