foxy88
1
Hello,
I want to apply a class dynamically depending on the variable content.
I am using the Dynamic Attribute and Class Toggle to do that.
This is the code that does not work:
<td dmx-text="version" dmx-class:classname="(version == '2.0') || (version == '3.0')"></td>
I think that the problem is because of the number 0.
If the zeroes are other numbers, it works.
Can you help me, please?
Can you use a different naming convention? Maybe OneZero and TwoZero instead?
foxy88
3
No because the values are returned by an API call.
Hmm, I’m wondering if it’s because the 1.0 is being treated as a number so becomes 1. Maybe use a formatter to change it to text?
foxy88
5
It should be already text, that is why I put the single quotes.
I can’t test this myself at the moment but wonder if it might still need a formatter to change it.
foxy88
7
I have just tried to format it to text using the version.toString() function without success.
Shame. Hopefully someone else can chip in with some other thoughts. Sorry I couldn’t solve it.
You can confirm this by looking at the results of the api in the dev console of your browser.
foxy88
10
As I wrote above, I confirm that the values are text.

TomD
11
Might something like this work:
dmx-class:classname="(version.value.toNumber() == 2 ) || (version.value.toNumber() == 3)"
?
I knew converting it was the answer… just got the thinking the wrong way round! 