I want to have a class on a div, if it is the last one in my repeat.
I have now:
<ui:repeat value="#{myCollection}" var="item" varStatus="status">
<div class="last">#{item.text}</div>
</ui:repeat>
but I want the class last just on the last div...
#{status.last}
is true, if it is the last div. But how can I get the class to the div?
Solution 1 if you may afford not to be compatible with IE8 :
Don't do this in JSF, this breaks the purpose of having a CSS to isolate the style from the data.
You may do this in your CSS file :
.normalClass:last-child {
}
Solution 2 :
<ui:repeat value="#{myCollection}" var="item" varStatus="status">
<div class="#{status.last?'last':''}">#{item.text}</div>
</ui:repeat>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With