Reserved word "items" in table query?

Have wasted hours trying to figure this one out and randomly fixed it.
Makes absolutely no sense to me :face_with_head_bandage:

Naming the server connect id=“items” and table bind.repeat=“items.data.query.data”. No rows populate under the table. In dev tools I can see that the data is coming through fine.
I recreated the database, server connect and entire page but still the same problem

<dmx-serverconnect id="items" url="/api/v1/items/get_all" dmx-param:active="query.active || true" dmx-param:archived="query.archived || false" dmx-param:sort="query.sort" dmx-param:dir="query.dir" dmx-param:offset="query.offset"
  dmx-param:limit="query.limit"></dmx-serverconnect>

<tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="items.data.query.data" id="tableRepeat">

By chance I renamed the serverconnect id and table bind to something else, but left the serverconnect url the same. Now it works ??

Since renaming fixed it, perhaps you had named both the server connect and the repeat “items” which would cause a problem?

We can see this by using

dmx.app.data

in the browser dev console.

It looks like this with just a server connect named items:

And if we add a table and set the tbody to “each_item” we have this:

But if we rename the tbody to items as you have done we get this:

The server connect is gone because the repeat has overwritten it.

And further, if we put the server connect after the table, instead of before it we get this:

The server connect has now overwritten the repeat.

Thanks for the tip @mebeingken but the repeat is named “tableRepeat”.

It seems like the repeat holds it’s items in an array called items :slight_smile: by default, and that’s messing it up.

When I first read that you were using “items” raised Red flags even though I’m not a Javascript pro.

It just seemed like one of those “using a reserved term” we get warned about in programming languages.

Today I ran across this link which I’ve bookmarked for myself because it shows working Examples for all kinds of common situations which Javascript can solve on the fly.

Array methods with Examples of each

The expression items.data.query.data is run in the scope of the repeater, from there it will look for the first identifier it finds with the name items. In this case it is a property of it’s own instance.

This is by design how the scoping works with App Connect. You already have found a solution/workaround, so will close this topic.

1 Like

This topic was automatically closed after 5 hours. New replies are no longer allowed.