Hi, Your code removes the element right away, and then calls the Fade effect, which naturally isn't what you want. That's because here:
> afterFinish: $('lightbox').remove() You're calling $('lightbox').remove() and giving its return value as the value of the `afterFinish` property. What you want to feed `afterFinish` is a _function_ to do that: new Effect.Fade( 'lightbox', { duration: this.animationTime, afterFinish: function() { $('lightbox').remove(); } } ); I'm sure there's a better way to access the lightbox element than the way I've done it above (I'm sure it gets passed into the callback somehow), but I'm not a scripty-head, so I don't know the details on that part of it. Look into the parameters passed into callback (I have a vague feeling they receive the effect instance and that it has an `element` property or something like that). HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Nov 30, 5:15 am, JoJo <tokyot...@gmail.com> wrote: > I want to remove an element from the DOM after fading it. > > new Effect.Fade( > 'lightbox', { > duration: this.animationTime, > afterFinish: $('lightbox').remove() > } > ); > > The above code works but gives me an error. Why is it still trying to > calculate opacity after it's finished? > > element is null > anonymous(Object name=element)effects.js (line 536) > anonymous()Lightbox.js (line 48) > function onclick(event) { lightbox.close(); }(click clientX=175, > clientY=190)2 (line 2) > [Break on this error] var oldOpacity = element.getInlineOpacity(); -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.