Problems with simple Toolbox/javascriptToBubble element setup

Hi, I’m experiencing a strange behavior of Toolbox plugin

Firstly, there is some little layout bug near bubble_fn_ field:

But my actual problem is another one: for some reason bubble does not recognize this value and does not let me to use this funciton inside JS workflow.

My setup is as follows:
There is a reusable named Shopping Cart Content, it has Cart as data type attached to it, and I’m trying to use Toolbox/JS to calculate sums of Prices of Cart Items multiplied by their respectful Amounts (or, at least, that’s the idea)
Inside that reusable I have jsToBubble element, which is setup as on picture above.
And I have a custom event in workflows for same reusable that tries to pass data to this jsToBubble:

For now I’m just trying to display a simple “1000” without any logic

I expect that this should work, but when i trigger this custom event in debugger, bubble seems not to recognize a function that should be set up by jsToBubble element and telling me it’s not defined:

I’m not completely sure if that’s a bug or if I’m missing something and would appreciate some help

upd: in case it’s helpful for investigating first issue, my browser is Opera 94.0.4606.76

Ok, after some amount of debugging I finally found an issue: apparently jsToBubble element does not register bubble_fn_.. function if it’s set to not be visible on page load (which I did automatically and forgot about it)
Not sure if that’s intended behavior, but my problem is fixed for now

Yep, element plugins must be “visible” to run. This is standard Bubble plugin behavior. (Basically, an element’s initialization routine is run once when it gets visible on the page. Its update function runs for the first time immediately after that.)

1 Like

Thanks for clarification, that’s very useful.
Does that mean that element visibility is a main mechanism which is used to manipulate page load order in cases when that’s essential for “visual load speed”?

“Main”, no. Also, utility element plugins like JStoBubble aren’t really designed to be hidden and then shown (though of course they can be). This particular plugin isn’t really a good example of modern element plugin design though as it’s quite old (basically as old as the plugin API).

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