Setting Style via Bindings

edited October 2013 in Enyo 2.4
Wanted to shared a quick tip on setting the style property via bindings in 2.3. You can set it like any other property but there are a couple gotchas. First, you have to set all the styles in one binding. You can use the transform function to customize the style property but it has to be done at one otherwise following bindings will overwrite the latter. Second, you can't both bind the showing property and the style property on a control. This is ultimately due to the first "gotcha" because setting showing is really just setting "display" within the inline CSS.

I did find a workaround, however. The third argument to the transform function is the enyo.Binding instance. This instance has source and target properties that map to each side of the binding. So, you can use target property to get a reference to the control and then use applyStyle() to append style elements.

enyojs team - feel free to share a better approach if you have one.
Sign In or Register to comment.