Looping a bubble list in javascript

Hi all,

I am trying to loop through a bubble list in javascript, in order to push data into a javascript chart.

The problem is that I can´t use the javascript variable (counter, in the example i) to select the item in the bubble list (item# ):


Is there a way to use the javascript variable, or is there a workaround?

Any help is appreciated

1 Like

The only way I know to send data from custom scripts back into Bubble is with Javascript to Bubble elements.
So before settings your dataPoint object you would call the function you configured in the element (ex. bubble_fn_loop(i);).

Then you’ll be able to refer to the item#:

Current User's PassPath:item # Javascript to Bubble element's value

You’d have to configure the Javascript to Bubble element to publish a number value


Thanks, this makes sense.

I am calling the bubble_fn_loop(i) when loading the page and using the # to loop my list.

The problem comes after, when I try to update the value on bubble_fn_loop(i + 1).

How I am suppose to update that value so I can loop through the list?


Well you only need to call bubble_fn_loop(i); since the for loop takes care of increasing the i.

The problem is not on the value used to call the function. The problem is that when I run bubble_fn_loop(X) in a HTML element, it does not run. Is it suppose to work from an html block?

Only seems to work when running it from the workflow javascript action.

1 Like

Might be possible that the function is called before the Javascript to Bubble element has loaded…
Perhaps you could add a while loop with a condition that tests if the typeof bubble_fn_loop() is “function” or “undefined” to determine whether to run the for loop or wait a bit to let the element loads.

This topic was automatically closed after 70 days. New replies are no longer allowed.