I have a library that checks if scriptaculous is loaded to show div with or
without effects. If the web has scriptaculous effects, I user a
Effect.Appear to show the div, else I show it with Element.show. The problem
comes when I need to execute an action after the div has been showed. I have
to write the same code two times, one with effects (with code on afterFinish
callback), and other without them (linear flow), because after showing the
div I need to execute some script but with the div totally visible. Maybe an
example will explain better than me (extract).
...
initialize: function()
{
//scriptaculous loaded?
this.hasEffects = String.prototype.parseColor != null;
this.options = Object.extend(
{
showEffect: ( this.hasEffects ? Effect.Appear :
Element.show ),
...
if ( this.hasEffects )
{
showEffect( myDiv,
{
afterFinish: function()
{
*action
}
}
}
else
{
showEffect( myDiv );
*action
}
...
If I use the "else" containment in both cases I get an error, because
the
*action need the div visible and the div is still on scriptaculous appear
effect.
Maybe there is some way yo avoid to rewrite two times the code without the
need to cut the library in a lot of mini functions
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---