Stack visual_effect - possible?

Is it possible to apply two visual_effect to the same DOM ID?

I can get it to work like this:

page[:current_item].visual_effect :highlight, :start_color =>
#fff”, :end_color => “#000
page[:current_item].visual_effect :puff

But can I call it like this:

page[:current_item].visual_effect :EFFECT1, :EFFECT2

Thanks!

most likely not a good idea.
i had some problems doing things like that, because starting an effect
stops the first one and leaves the item in some intermediate state.
seems, there can be only one active effect at all.
(maybe that’s fixed in newer versions, i didn’t try this for quite some
time now)

If you want to run multiple sequential effects, use this rarely
documented option:

visual_effect(:highlight, “posts”, :duration => 0.5, :queue=>‘end’)

If you want to run multiple effects simultaneously, you need to
subclass an effect in the scriptaculous library and combine them
programatically.

Thanks - I will give that a shot.

Clever N. wrote:

If you want to run multiple sequential effects, use this rarely
documented option:

visual_effect(:highlight, “posts”, :duration => 0.5, :queue=>‘end’)

How would that work? How can I have two visual effects when something
is clicked?

<%= content_tag ‘div’, truncate(@linklog.notes, 40, “…”), :id =>
“initial#{@linklog.id}”, :onclick => visual_effect(:toggle_blind,
“link_body#{@linklog.id}”, :duration => 1.0, :queue=>‘end’) %>

The rails javascript helpers can be handy but it’s important to
understand what they do.
visual_effect(…) just spits out new Effect.Something($
(‘some_id’), …)

so if you want 2 effects created then visual_effect(…) + ‘;’ +
visual_effect(…) will do the job.

Fred
Thanks, that was the exact answer I was looking for :slight_smile:

On 10 Jul 2008, at 18:07, Joe P. wrote:

Clever N. wrote:

If you want to run multiple sequential effects, use this rarely
documented option:

visual_effect(:highlight, “posts”, :duration => 0.5, :queue=>‘end’)

How would that work? How can I have two visual effects when something
is clicked?

There are two separate issues here: whether effects run in parallel,
sequentially etc and then the business of actually creating an effect

<%= content_tag ‘div’, truncate(@linklog.notes, 40, “…”), :id =>
“initial#{@linklog.id}”, :onclick => visual_effect(:toggle_blind,
“link_body#{@linklog.id}”, :duration => 1.0, :queue=>‘end’) %>

The rails javascript helpers can be handy but it’s important to
understand what they do.
visual_effect(…) just spits out new Effect.Something($
(‘some_id’), …)

so if you want 2 effects created then visual_effect(…) + ‘;’ +
visual_effect(…) will do the job.
You will need to look into the queue options (or effect.parallel in
friends) if you want to play around with which one happens first,
whether they run sequentially or not etc…

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs