> Thanks!
No worries. I should have mentioned -- although I'm sure you realize
-- that you can create the options once and reuse them:
var fxoptRestoreStyle = {
beforeStart: function(effect) {
effect.saveStyle = effect.element.style.cssText;
},
afterFinish: function(effect) {
effect.element.style.cssText = effect.saveStyle;
}
};
[...]
$('target').highlight(fxoptRestoreStyle);
[...]
$('foo').shake(fxoptRestoreStyle);
etc. If you have other options to include and want to mix these in,
Object.extend[1] will help:
$('target').highlight(Object.extend({duration: 5.0},
fxoptRestoreStyle));
[1] http://prototypejs.org/api/object/extend
Happy coding,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available
On Jul 18, 5:10 am, Nicholas Van Weerdenburg <[email protected]>
wrote:
> Thanks!
>
> On Fri, Jul 17, 2009 at 10:42 AM, T.J. Crowder
> <[email protected]>wrote:
>
>
>
>
>
> > Hi,
>
> > Yeah, bit of a pain that there's no standard way to _remove_ a style
> > from the style property entirely. Setting things to "" is not the
> > same thing.
>
> > However: Effects offer beforeStart and afterFinish callbacks, and the
> > style property has this nifty cssText property on it, which suggests
> > this should work around the problem (and may be a way forward for an
> > eventual scripty fix):
>
> > $('target').highlight({
> > beforeStart: function(effect) {
> > effect.saveStyle = effect.element.style.cssText;
> > },
> > afterFinish: function(effect) {
> > effect.element.style.cssText = effect.saveStyle;
> > }
> > });
>
> > cssText is fairly widely supported, I believe, even IE6 had it (not
> > that :hover works with IE6, except on links). In fact, Prototype's
> > setStyle uses it if you pass in a string (an undocumented feature;
> > docs say it has to be an object, so it may not get unit tested).
>
> > HTH,
>
> > On Jul 17, 2:33 pm, Nicholas Van Weerdenburg <[email protected]>
> > wrote:
> > > Hi,
> > > I found this tickethttp://dev.rubyonrails.org/ticket/6134
>
> > > but the problem still exists. No matter what I do, Effect.Highlight
> > > pollutes the DOM by changing the element background color, breaking css
> > > :hover and other style rules due to the element rule css precedence
>
> > > Anyone know of a workaround? I tried :restorecolor=>"" but that doesn't
> > > work. Calls to set the background color to "" fail, I think due to the
> > > timing of the hightlight.
>
> > > Thanks,
> > > Nick
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---