# Dynamically create/add an element

**URL:** <https://forum.bubble.io/t/dynamically-create-add-an-element/129842>\
**Category:** Need help\
**Created:** [January 10, 2021, 2:07pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842 "2021-01-10T14:07:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nbege](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nbege](https://forum.bubble.io/u/nbege)\
**Post date:** [January 10, 2021, 2:07pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/1 "2021-01-10T14:07:06Z")

</div>

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 😃

---

<div class="post-metadata">

**Author:** ![cmarchan](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/cmarchan/32/253062_2.png) [@cmarchan](https://forum.bubble.io/u/cmarchan)\
**Post date:** [January 10, 2021, 2:14pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/2 "2021-01-10T14:14:24Z")

</div>

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. 👍🏻

---

<div class="post-metadata">

**Author:** ![nbege](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nbege](https://forum.bubble.io/u/nbege)\
**Post date:** [January 10, 2021, 2:23pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/3 "2021-01-10T14:23:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![feee](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@feee](https://forum.bubble.io/u/feee)\
**Post date:** [January 10, 2021, 2:30pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/4 "2021-01-10T14:30:18Z")

</div>

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](https://wrld897235-34.bubbleapps.io/version-test)  
And then check the editor: [https://bubble.io/page?name=index&id=wrld897235-34&tab=tabs-1](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.

---

<div class="post-metadata">

**Author:** ![nbege](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nbege](https://forum.bubble.io/u/nbege)\
**Post date:** [January 10, 2021, 2:52pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/5 "2021-01-10T14:52:43Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![feee](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@feee](https://forum.bubble.io/u/feee)\
**Post date:** [January 10, 2021, 2:57pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/6 "2021-01-10T14:57:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nbege](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nbege](https://forum.bubble.io/u/nbege)\
**Post date:** [January 10, 2021, 3:19pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/7 "2021-01-10T15:19:49Z")

</div>

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… 🤔

---

<div class="post-metadata">

**Author:** ![feee](https://avatars.discourse-cdn.com/v4/letter/f/85e7bf/32.png) [@feee](https://forum.bubble.io/u/feee)\
**Post date:** [January 10, 2021, 3:22pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/8 "2021-01-10T15:22:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [March 21, 2021, 2:07pm UTC](https://forum.bubble.io/t/dynamically-create-add-an-element/129842/9 "2021-03-21T14:07:07Z")

</div>

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