Can an AC repeat source expression be changed dynamically?

i.e with a ternary operation. I haven’t been able to figure this one out.

Do you mean server side or client-side?
I’ve managed to do it client-side but haven’t tried on the server

Client.

Yes, that is possible. A simple example:

 dmx-bind:repeat="var1.value == 1 ? 10 : 5"

So if var1 value is 1, the repeat will repeat its items 10 times, otherwise 5.

2 Likes

I used it on a table repeat so that it looked at the value of a select input (to filter results to a team if ‘all’ wasn’t selected:

dmx-bind:repeat="inp_fixtureteamselect.value == 'all' ? sc_getfixtures.data.q_getfixtures_currentseason : sc_getfixtures.data.q_getfixtures_currentseason.where('fixturesteam', inp_fixtureteamselect.value, '==')"
1 Like

Thanks for the confirmation guys.
My problem was lying in the api call itself and not the expression. Yup. Confirmed it works as you mentioned.

Although for testing purposes the UI doesn’t play well with this:

dmx-bind:repeat="true ? api1.data.hits : null"

image

image

1 Like

What does this expression mean?

true ? api1.data.hits : null

i mean the true part?

Force to evaluate to the second operand always. And with false evaluate to the third operand.
While dealing with my underlying issue(the api call itself and not the ternary) I was doing some tests to rule out an issue with the ternary.

Not a thing for me as nobody would use that ternary condition in a real live example unless they are psychopaths.

Just wanted to mention that the UI doesn’t play well with the psycho ternary :smiley:

2 Likes

Ok, so the issue here is it adds the + after true, right?

Yup.

You are indeed a real psychopath :smiley: in my tests i am usually using 1 == 1 ? 10 : 5 and i thought 1 == 1 is a psycho condition, but you beat me :smiley:

1 Like

Imagine if you did.

0 ? 1 : 0

Charles Manson level.

tenor

1 Like