I’m trying to use a Bubble expression inside a javascript loop. The expression is supposed to change with each loop using the Toolbox plugin’s Javascript to Bubble element. I try to store the value of the bubble expression inside an array. But the array is storing the same value in every index. I feel like the array is storing the bubble expression in each index instead of the value of the expression, which is why I think I’m getting the same number.
Anybody have an idea of what could be causing this, and how to fix it? Thanks!
Here is the code. It results in an array that equals 4,4,4,4,4. I would expect it to result in 0,1,2,3,4.
“dayIteration” is from Javascript to Bubble Toolbox plugin.
Are any of your toolbox elements inside of a repeating group?
There’s a number of possibilities that could be going on. It could be that its grabbing the value of dayIteration at the start of running the javascript and using that value throughout. It could also be that the code in the loop is running faster than the javascript to bubble element can publish the value, so its just using the older values.
Is there a way you can restructure the code such that it doesn’t rely on the result of a call to a javascript to bubble function? Or is there a way you can call the function with an array [0, 1, 2, 3, 4, 5] and then have the javascript to bubble function return a list of values?
We help founders bridge the gap between their current bubble app and their MVP. Learn more at https://protomakr.com
Thank you both for your quick responses. I’ve explored several other ways fix this, but it looks like I need to try a different approach other than adding data from a loop to the Javascript to Bubble element.