Hello. I recently started app development.
I am creating a simple app.
I want to place three lines of text below the button.
How can I display three random pieces of data from a set of ten every time a button is pressed?
I tried using Repeating Group, but my approach didn’t work out well.
Thank you in advance.
Hi there, @pineapple777… when the button is clicked, try running a workflow that looks like this.
Hope this helps.
Thank you so much. I was able to display three random texts easily.
However, with this method, pressing the button only updates once.
How can I make it update every time I press the button?
I apologize for the inconvenience.
I would greatly appreciate it if I could receive a response.
Thank you very much.
Try adding the Clear list workflow action in front of the action in my screenshot to clear the repeating group’s list before displaying the three random items.
I tried such a method, but it didn’t work well.
How can I repeat the same action within the workflow?
It may be a basic thing, but I’ve tried various things and still can’t do it.
I apologize, but I would appreciate further assistance.
This is a tricky one because Bubble isn’t actually “re-randomizing” the search since it already searched and cached it locally once…
Wow, that really is tricky (sorry, @pineapple777, I usually test my suggestions first), and after trying a lot of stuff, I might have come up with the worst solution ever. It involves faking the re-randomizing of the search by setting 3 custom states to random numbers between 1 and 10 when a button is clicked and making sure the random numbers in the states are not the same. Then, I set the data source of the repeating group to this monstrosity.
While it actually does what OP wants, I expect to be thoroughly ridiculed for this mess, and I would love to know how someone would solve this one for real.
The other (stupid) method I was gonna suggest was make an API workflow that returns a search for 3 random items, then call that workflow via API connector
Stupid in the sense that this even has to be done but I’m sure it would work cause there’s no front end caching.
Guys… I don’t know if I understood well, but I came with a very simple solution
4 custom states in the page
- texts (Type text / List)
On Page Load, run a workflow to import all desired texts inside the custom state “texts”
Now, when click the button run a workflow with 3 actions:
- Change custom state “text1” to a random item in custom state “texts”;
- Change the custom state “text2” to a random item in custom state “texts” MINUS the item designated to be the custom state “text1”
- Change the custom state “text3” to a random item in custom state “texts” MINUS the item designated to be the custom state “text1” MINUS the item designated to be the custom state “text2”.
Knowing you guys, I assume you are both tired
Um, yeah, tired… I’ll blame my ridiculous solution on that.
Maybe if random sorting worked like it says it does I would get some sleep
Wow, I’m truly grateful for all the suggestions.
I thought it was something basic, but it seems quite challenging for someone like me who is a beginner.
I will do my best to try my hardest. Thank you so much for taking the time to help me and for investing significant effort.
This topic was automatically closed after 70 days. New replies are no longer allowed.