0

I have a code that looks like this.

<%= link_to_remote "View results",
{
    :update=>"uxUpdateDiv" ,
    :url=>{:controller=>"exam", :action=>"results"}  ,
    :loading=>visual_effect(:appear, "uxcLoader", :duration=> 0.1),
    :before =>visual_effect(:fade, "uxUpdateDiv", :duration => 0.1),
    :complete => visual_effect(:appear, "uxUpdateDiv", :duration => 1.5 ),
    :success=>visual_effect(:fade, "uxcLoader", :duration=> 1)
}
%>

what happens here is not good enough for me.

I want to add multiple effects for one event. Like the following:

 :complete=>(:fade, "uxLoader", :duration=>1 AND :fade, "uxTheOtherDiv", :duration=>1)

How do i achieve this.? I am using jrails

ZX12R
  • 4,760
  • 8
  • 38
  • 53

2 Answers2

3

You can write like this:

:complete=>update_page do |page|
            page.visual_effect :fade, "uxLoader", :duration=>1
            page.visual_effect :fade, "uxTheOtherDiv", :duration=>1
           end

See the api.

dombesz
  • 7,890
  • 5
  • 38
  • 47
  • thanks..is the order in which we give going to be the queue order? – ZX12R May 11 '10 at 09:47
  • Do you refer to chaining the effects? If thats the case its better to write javascript code like the comment above. Because the chaining is a javascript library specific function. You can do like this: :complete => "$('uxLoader').fadeIn(1000,function() { $('uxTheOtherDiv').fadeIn(1000));});" – dombesz May 11 '10 at 10:34
0

Using straight jQuery?

:complete => "$('uxLoader').fadeIn(1000); $('uxTheOtherDiv').fadeIn(1000);"
nathanvda
  • 49,707
  • 13
  • 117
  • 139
  • inside your :complete you can just write the javascript; so just replace your :complete line with mine above. This is how i do it all the time. – nathanvda May 11 '10 at 11:38