Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data binding of CSS class attribute in XML view

How can I bind the value of the CSS class attribute of a XML fragment to a model property within another XML view?

The following snipped works fine

<core:Fragment fragmentName="com.foo.bar.Fragment" type="XML" class="important"/>

and should be changed to something like

<core:Fragment fragmentName="com.foo.bar.Fragment" type="XML" class="{itemStatus}"/>

where {itemStatus}should be bound to model property.

Any help appreciated!

like image 281
z00bs Avatar asked Jan 08 '15 15:01

z00bs


1 Answers

Unfortunately, it is indeed not possible to bind the class attribute, as Qualiture already mentioned. However, there is a workaround using custom data, which can be bound, written to the DOM and hence also used for styling purposes. You can see an example here in the documentation: Writing Data to the HTML DOM as DATA-* Attribute

Hope that helps

like image 104
10littleOrcs Avatar answered Oct 15 '22 01:10

10littleOrcs