Dynamically create/add an element

Hi!
Is there a way to dynamically create an element - I mean not just show/hide it? For instance, in order to display an unanticipated number of shapes or inputs based on a user input?
Thanks for your help :smiley:

1 Like

Create a dB data type call it ā€œelementā€
Build an rg with the element you want inside an rg row group that you will use to establish conditions
Set the content to ā€œelementā€ and the data source to a search for elements
You need a trigger. For this example letā€™s add a button outside of the rg. Set it to create a dB element upon being clicked.

The above is super basic I know, but hopefully it sparks some ideas. :+1:t2:

2 Likes

Thanks for the idea! I already tried something like that but Iā€™m lost when trying to configure the size and positioning of the RG. Especially since, in an ideal world, I would have loved to have different element sizes and positions in each ā€œsquareā€. I was thinking maybe thereā€™s a way to ā€œcallā€ a Bubble element using a (simple) javascript?

Iā€™ve done something similar in the past, this app can automatically generate a population visualization using bubble.
Each time you add population it shows a dynamic shape based on the number of population added to each area of the map.
Try it yourself: https://wrld897235-34.bubbleapps.io/version-test
And then check the editor: https://bubble.io/page?name=index&id=wrld897235-34&tab=tabs-1

Itā€™s not a nice solution but everything is possible with bubble.

There is even a time-lapse feature that shows how the population has evolved overtime.

Interesting indeed (and well done!) but, if Iā€™m not mistaking, this is still dynamic show/hide where you have to anticipate in the condition tab all possible outcomes on the page? In the case of the app Iā€™ve got in mind, that would mean the programming of tens if not hundreds of situations - way too fastidious to build and maintain error-freeā€¦ But thanks for the inspiration!

1 Like

Using repeating groups and underlying data you arenā€™t hiding and showing it.
So basically if you want a dynamic amount of inputs then you build a repeating group with a single piece of input.
Then you create a data type called ā€œInputsā€ and then you create a button that will create a new ā€œInputā€ data and then the repeating group will show a new input field every time you click the button. This is pretty dynamic imo.

1 Like

Youā€™re right and I can see how it works fine in order to display an expanding view of identical elements like your green dots. But thatā€™s not exactly what I want. And if itā€™s not possible to make the app create an element on the fly (something like ā€œbuild X shapes/textboxes/inputs of these sizes and put them at these coordinatesā€), that means I probably have to rethink my project and find a more practical logic to anticipate the user inputā€¦ :thinking:

There is a plugin to move elements to any coordinates but youā€™d likely have to create the shapes and inputs manually.

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