I wanted to set a Condition based upon the selection within a Drop-Down Menu. This is the Drop-Down Menu…
And here is the html as seen in DevTools…
If I enter things manually, like this, it works well…
dmx-bind:condition="[1,9].contains(select1.selectedValue.toNumber())"
But using the Bindings interface, things fail.
Here it is hand-coded in the Code view…
But this is how the same thing shows in Design view…
And this is what happens when you try to use the Data Formats panel, and the subsequent Error Notification…
I cannot set it in the Data Bindings panel. Is this an error or am I doing it wrong?
Teodor
December 15, 2021, 6:15pm
2
What is the condition you are trying to check?
If the value “1” or “9” are selected then show this code.
Teodor
December 15, 2021, 6:29pm
4
so why not simply…
dmx-bind:condition="select1.selectedValue == 1 || select1.selectedValue == 9"
Because the values will end up being dynamic and could contain, say, 20 different values.
Teodor
December 15, 2021, 6:32pm
6
You are saying that this part [1,9].contains
is going to be dynamic, or?
Yes.
So it could be an array.
But it isn’t at the moment. As it stands now it could be up to say 6 values.
Teodor
December 15, 2021, 6:40pm
8
Tested locally with a dynamic array value and it works fine:
Probably there is an issue with entering [1,6]
in the UI as it’s not really expected as a value there. Not sure if this can be improved @George
I appreciate your help as always.
So from what you say, I will be better off setting up an array manually.
Not sure how I should do that as this doesn’t work…
I think I have done it correctly now
So the array looks like this
<dmx-array id="arr1" dmx-bind:items="[1,9]"></dmx-array>
Hand-coded within the Code view…
And the Condition now looks like this…
dmx-bind:condition="arr1.items.contains(select1.selectedValue.toNumber())"
The only problem with this (not that it really is a problem!) is that I’ll need to set up lots of different array variables rather than hand-coding within the Condition code each time.