Our interface calls for buttons that change color dynamically to represent different states - sort of alert levels if you will.
(Sidebar: I searched for ways to make my own custom states, and found nothing in the forums or documentation. I derived my own button type and started adding a customState property and a setCustomState method. This led to some odd behavior. Turns out these both already exist, undocumented it seems, in SmartClient (StretchImg I think). So, I dropped my derivation and am using this undocumented feature.)
So, I've got these buttons and I call myButton.setCustomState('CodeRed') and a lot of things happen like I want, all for free, and I'm very happy with that. The button images swap out to the correct colors, the icon image will change, and the value for the class attribute(s) on the DOM elements change the CSS rule. Calling myButton.setCustomState('') will set things to the default button state. All of this is very, very nice.
There is one problem I am having though, and need some tips on how to go about fixing that. The CSS rule change (via setting the class attribute on the DOM element) does not take effect immediately. I can see in FireBug that the class changes from class="buttonTitleCodeRed" to class="buttonTitleCodeYellow" but the rules defined in the css do not get applied until an event like MouseOver occurs. Specifically in my case, the red buttons have a white font color, but the font color must be made much darker on the yellow buttons. The font color doesn't reflect a change until I mouseover the button.
(Sidebar: I searched for ways to make my own custom states, and found nothing in the forums or documentation. I derived my own button type and started adding a customState property and a setCustomState method. This led to some odd behavior. Turns out these both already exist, undocumented it seems, in SmartClient (StretchImg I think). So, I dropped my derivation and am using this undocumented feature.)
So, I've got these buttons and I call myButton.setCustomState('CodeRed') and a lot of things happen like I want, all for free, and I'm very happy with that. The button images swap out to the correct colors, the icon image will change, and the value for the class attribute(s) on the DOM elements change the CSS rule. Calling myButton.setCustomState('') will set things to the default button state. All of this is very, very nice.
There is one problem I am having though, and need some tips on how to go about fixing that. The CSS rule change (via setting the class attribute on the DOM element) does not take effect immediately. I can see in FireBug that the class changes from class="buttonTitleCodeRed" to class="buttonTitleCodeYellow" but the rules defined in the css do not get applied until an event like MouseOver occurs. Specifically in my case, the red buttons have a white font color, but the font color must be made much darker on the yellow buttons. The font color doesn't reflect a change until I mouseover the button.
Comment