I have a text element on a dynamic page that is displaying the value of a text field in one of my collections. In this example it shows “Easter”
I am querying with this text value using .eq but instead of the value being “Easter” it shows as “title” which is its default text value.
I understand the default value for my text element is being retrieved BEFORE the dynamic page content is populated and I know this can be fixed with setTimeout() but is there another, more secure way?
I currently have my code in an onReady function
const collectionTitle = $w("#title").text;
// Query the "Songs" collection based on collectionTitle
wixData.query("Songs")
.eq("collection", collectionTitle)
.find()
.then(results => {
// Check if there are results
if (results.items.length > 0) {
// Show the "listRepeater" and hide the "errorMessage"
$w("#listRepeater").data = results.items;
$w("#listRepeater").show();
$w("#errorMessage").hide();
} else {
// Show the "errorMessage" and hide the "listRepeater"
$w("#listRepeater").hide();
$w("#errorMessage").show();
}
})