Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3738 (closed defect: duplicate)

Opened 3 years ago

Last modified 2 years ago

Effect.Highlight unconditionaly sets the style attribute on the element

Reported by: Yuri de Wit Assigned to: thomas@fesch.at
Priority: normal Milestone:
Component: script.aculo.us Version:
Severity: normal Keywords: Highlight Effect
Cc: ydewit@gmail.com

Description

Here is the context: I want to use Effect.Highlight but I want to be able to specify the start and end colors using CSS instead of hardcoding it in my JS. The problem is that Effect.Highlight is unconditionally setting the style attribute on the element when the effect finishes even if that style actually came from CSS. The effect runs as expected only the first time.

In my example, I want to highlight an input element when the user makes a change to it. So I created a class 'updated' in CSS that defines the background-color, i.e. the effect start color. Before applying the effect I get the current background-color for the input element, i.e. the effect start color, add the 'updated' class, get the new background-color, i.e. the start color, and remove the added class. Then I apply the effect. After the first time the input is changed, the effect appears as expected, but the background-color style is set on the element. Any subsequent changes will not work because now the background-color after and before the class is added is the same, i.e. the end color.

I looked into the Effect.Highlight implementation and it seems that both the background-color and background-image styles should only be set on the element in the Highlight.finish() method IFF they explicitly existed on the element before the effect was applied.

Change History

07/10/06 11:09:15 changed by anonymous

Also because of described problem I cannot use images instead of 'Saving...' text because Effect.Highlight set 'background-image' to 'none'

08/17/06 17:12:41 changed by tomg@byu.net

See also #3454

09/13/06 00:53:28 changed by bitsweat

  • status changed from new to closed.
  • resolution set to duplicate.