I thought that hiding a repeating group (making it not visible on page load) was supposed to prevent its data source from loading. However, when my page loads, the RG data loads and flashes briefly on screen before disappearing.
I have several RG’s on a SPA-like page, and I want to improve performance by preventing DB data loads until the RG is explicitly made visible by a user interaction. How is this done?
The odd thing is that I swear it WAS working the way I thought it should, but now data from all RG’s, despite them being set to NOT visible on page load, appears briefly before disappearing. Is there a trick?
Holy hannah! I just discovered that using a state of type “number” instead of type “thing” solved the issue! I have no idea why, but it worked!
I was displaying specific RG’s based upon which item in another RG was clicked, and I was storing the clicked “thing” in a state to keep track of the currently selected “thing”. Using the index of the thing instead of the thing itself solved the problem. For good measure, I’m also conditionally setting the data source at the same time it’s made visible (although it was working without doing so).
Now, there’s no ugly flash, and the data loads only when the RG is made visible - just what I wanted. Too bad it took 90 minutes of fiddling to stumble upon the solution. Go figure.
Thanks, @anon65040322. I didn’t actually try that, so it might have worked, but I don’t see why it should be necessary. An RG is a group after all. Besides that, I try hard to minimize the number of elements on the page to keep it as “light” as possible - especially given the number of divs that Bubble already outputs. Minimizing the amount of “nesting” also keeps things a bit more sane and manageable in the editor.
An element won’t perform its search if hidden on page load, UNLESS you reference that result from another element. So for example, if you have a lengthy search on an rg, and keep it hidden but then have a text element that displays the count of those results, it will do the search.
Thanks, @Kfawcett, but that’s exactly what I was doing. I had unchecked the This element is visible on page load property in the editor; and I was using a “when current thing [stored in a state] is a specific thing in a list of things” condition to make an RG visible.
The bizarre-o thing is that it WAS working by storing the “thing” in a state until I started tweaking other aspects of the page.
Thanks, @mebeingken. I just double checked the logic, and nowhere was I referencing the RG to be made visible. There are actually multiple hidden RG’s on page load, and they all appeared briefly before disappearing. It’s as though they were initially set to visible and then being hidden on page load.
I think my take-home, though, is that henceforth I’ll use indexes to keep track of currently selected (clicked) things in an RG list.