# Ajax effects

**URL:** <https://www.ruby-forum.com/t/ajax-effects/97669>\
**Category:** Rails\
**Created:** [July 9, 2006, 11:01am UTC](https://www.ruby-forum.com/t/ajax-effects/97669 "2006-07-09T11:01:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 11:01am UTC](https://www.ruby-forum.com/t/ajax-effects/97669/1 "2006-07-09T11:01:00Z")

</div>

Hi,

i was wondering if there was some kind of general line of code i could  
add to my application, anywhere i suppose, that would generate some kind  
of effect to notify the user that an effect is happening…it could be a  
box on the top of the screen or something, that would be like the small  
bar at the end of the browser that shows the user the status of a  
loading page … i was hoping instead of going to each specific place i  
put ajax on a page, i could just add a  
when @HTTPrequest == something(or something similar) then javascript  
Effect (or something)  
(and not going to every specific place and do :complete =\> …etc)

is this even possible?

thanks…

: )

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 2:24pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/2 "2006-07-09T14:24:20Z")

</div>

I have a link that does some background processing so I used :-

\<%= link\_to\_remote(“Link Name”, :url =\> {:action =\> ‘link\_action’},  
:before =\> %(Element.show(‘spinner’)),  
:success =\> %(Element.hide(‘spinner’))) %\>  
\<%= image\_tag ‘spinner.gif’, :id =\> ‘spinner’, :style =\> ‘display:  
none;’ %\>

in the view. All this does is display an animated spinner.gif when  
the job is running. It’s then hidden when it’s finished.

If you have the Agile Web D. with Rails book then there is a  
similar example on page 403.

Carl

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 2:45pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/3 "2006-07-09T14:45:00Z")

</div>

I Heard Decay wrote:

> ```
> :before => %(Element.show('spinner')),
> :success => %(Element.hide('spinner'))) %>
> 
> ```

Dear Decay heard,

thank you for your reply. much appreciated.  
the deal is, i’ve got around six/seven ajax actions on a certain page  
(including ajax forms and such) and i was hoping that instead of going  
to each one and putting a :before/:complete/:success on each one, there  
was a different approach, like writing down HTTP\_REQUEST/something or  
some kind of command that recognizes the action taking place an ajax  
one(if there is such a command, and i do believe there is one) and then  
putting a general effect on that (that will take place on each ajax  
command taking place)

if this is not possible, so be it…i’ll implement the effects one by  
one, but i was hoping there was a different approach to it. is there? i  
may be wasting my time…either way,

thanks for the reply,

unknown

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/4 "2006-07-09T15:13:27Z")

</div>

Hi –

On Sun, 9 Jul 2006, unknown wrote:

> was a different approach, like writing down HTTP\_REQUEST/something or  
> some kind of command that recognizes the action taking place an ajax  
> one(if there is such a command, and i do believe there is one) and then  
> putting a general effect on that (that will take place on each ajax  
> command taking place)
> 
> if this is not possible, so be it…i’ll implement the effects one by  
> one, but i was hoping there was a different approach to it. is there? i  
> may be wasting my time…either way,

An RJS template maybe?

David

–  
[http://www.rubypowerandlight.com](http://www.rubypowerandlight.com) =\> Ruby/Rails training & consultancy  
[Ruby for Rails](http://www.manning.com/black) =\> RUBY FOR RAILS, the Ruby book for  
Rails developers  
[http://dablog.rubypal.com](http://dablog.rubypal.com) =\> D[avid]A[.]B[lack’s][Web]log  
removed\_email\_address@domain.invalid =\> me

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 4:42pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/5 "2006-07-09T16:42:18Z")

</div>

> An RJS template maybe?
> 
> David

…maybe. how do i do this? any info i could get my hands dirty with?  
i’ve seen RJS all around, but don’t really know what it’s all about…?  
thanks,

unknown

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/6 "2006-07-09T18:00:46Z")

</div>

unknown [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> > An RJS template maybe?
> > 
> > David
> 
> …maybe. how do i do this? any info i could get my hands dirty with?  
> i’ve seen RJS all around, but don’t really know what it’s all about…?  
> thanks,

There is a book on RJS buy that. Or search around in blogosphere for  
articles  
explaining RJS.

## HTH.

Surendra S.  
[http://ssinghi.kreeti.com](http://ssinghi.kreeti.com), [http://www.kreeti.com](http://www.kreeti.com)  
Read my blog at: [http://cuttingtheredtape.blogspot.com/](http://cuttingtheredtape.blogspot.com/)  
,----  
| “War is Peace! Freedom is Slavery! Ignorance is Strength!”  
| – Orwell, 1984, 1948  
`----

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 9, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/ajax-effects/97669/7 "2006-07-09T18:26:25Z")

</div>

Take a look at this plugin. It might accomplish what your looking for.

[http://www.agilewebdevelopment.com/plugins/remote\_helpers](http://www.agilewebdevelopment.com/plugins/remote_helpers)

I believe its an extension to the link\_to\_remote et al rail functions.

Cheers,  
Adam
