Hello,
I have been trying to code using VeloJS recently and I have found a weird issue that cannot seem to be resolved no matter how much I tried to debug it.
The only hint I have is that this line:
let t = $w("#text21").text
The issue is that the variable t is supposed to store a Title field’s value, which is generated into a text element, in order to recognize which ITEM we are currently at.
Full code:
let t = $w("#text21").text;
const tobj = {
"Falon" : ["#8F715F", "#FFEFDF"],
"Gris" : ["#D2D2D2", "#4A4442"],
"Noir" : ["#393939", "#D8D8D8"],
"Noir V" : ["#222222", "#ECBF92"],
"Rosé" : ["#FFDDBC", "#5E4436"],
"Or V" : ["#C1A66A", "#F5EBD8"]
};
// convert object to key's array
const keys = Object.keys(tobj);
console.log(keys);
// iterate over object
keys.forEach((key, index) =>
{
console.log(t + ":" + key);
console.log(index);
if(t === key)
{
//console.log(1245);
$w('#button5').style.backgroundColor = tobj[key][0];
$w('#button5').style.color = tobj[key][1];
}
});
Console logs:
NOTE: the first item is returning exactly what I need, the condition, in this case, is the item named “Noir”, which is the trigger to the button changing in style, and the console logging that the stored variable “t” is EQUAL to “key”, the key represents each key in our “tobj” object.
Noir:Falon
0
Noir:Gris
1
Noir:Noir
2
Noir:Noir V
3
Noir:Rosé
4
Noir:Or V
5
First item working fine.
Whenever I try to request the other items, it keeps returning this weird “1” from the stored variable “t” which is exactly the issue that I cannot seem to fix:
1:Falon
0
1:Gris
1
1:Noir
2
1:Noir V
3
1:Rosé
4
1:Or V
5
What do you think is not letting that variable “t” store the item’s Title field on each new page load?