We don't need no stinkin' "new"
There seems to be a bit of confusion among people not too familiar with Scriptaculous library. I often hear questions like “Why is
new Effect.BlindDown('myElement') is not working? Am I not passing myElement correctly?”. No, the situation is much simpler.
As of 1.7.1 Scriptaculous has 6 Core Effects:
All of the core effects should be INSTANTIATED. This means that we use “new” keyword in front of them:
new Effect.Opacity('myElement'); new Effect.Move('myElement');
Even though the correct syntax is clearly stated in wiki, it is sometimes not obvious and could be easily missed. These kind of things could make beginners bang their head against the wall for hours.
On the other hand, there is an extensive set of Combination effects:
- Effect.Appear, Effect.Fade
- Effect.BlindDown, Effect.BlindUp
- Effect.SlideDown, Effect.SlideUp
These do NOT need “new” keyword and essentially are just static methods of Effect object:
I hope this clears all the confusion.
Did you like this? Donations are welcomecomments powered by Disqus