Inconsistent Results When Using Variables Inside a Repeat

Is it “Legal Wappler” to put variables inside a repeat statement in HTML?

I am doing this as described below, but I’m getting irratic results with regard to the variable values being updated correctly based on the server connect data that has been loaded.

Does it make any difference if the repeat is a repeat children?

The details are below!

Antony.

= = = = = = = = = = = = = = = = = =

I have a repeat which lists the attendees at an event and then a column for 4 different messages they may have been sent. It looks like the image below.

I have a code structure something like this:

repeat attendees
   16 variable definitions which reference a value from the repeat
   HTML for each row as shown below.

The variable definitions look something like this:

<dmx-value id="mt1_sent" dmx-bind:value="activity_msrs.data.msrs.where(`status_`, 's', &quot;==&quot;).where(`sent_by`, 'e', &quot;!=&quot;).where(`contacts_to`, contact, &quot;==&quot;).where(`message_template`, mt1.value, &quot;==&quot;).count()"></dmx-value>

where contact is a value which comes from the repeat statement.

So what problems do you have exactly and when?
Also it would be better to post the exact code/link instead of:

repeat attendees
   16 variable definitions which reference a value from the repeat
   HTML for each row as shown below.

Well @Teodor, could you answer my main question first?

And then also my second question?

If the answer to the first question is yes, then it is worth me spending time documenting more of the details!

Best wishes,
Antony.

I don't really understand your question. What exactly are you doing there on your page?

My question is this:

If I put a variable inside a repeat which repeats ‘n’ times, and the variable is dependent on a value taken from the repeat (so as I documented, in this case contact), can I expect Wappler to create ‘n’ copies of the variable each with its own value, based in my example, on the different value of contact for each item repeated?

Yes, the variable will be created n times and the value of each variable instance will be available in its own scope.

Great, thank you @Teodor.

Does the way this works change whether I use a repeat or a repeat child?

The repeat children is the actual repeat component in App Connect, the other one - repeat is a dynamic attribute.

Only component have properties, data and events which you can use. So you are almost every time better using repeat children.

Great… let me try with a repeat children then!

I can’t wait to see your app, @Antony. :+1:

1 Like

Glad to hear you are excited about it @sitestreet!

I can’t wait either… right now it seems so near to completion yet still so far away! :slight_smile:

2 Likes