I have been having an issue for days so i am hoping someone can help! I have a multi file-uploader on a page, and i would like to allow users to preview an .stl file they have uploaded before submitting and saving to database, to achieve this i have set a custom state.
In order to render the file i have using three.js. The issue is that whatever i try, Bubble fails to prepend HTTPS or the Current Cell Index with the correct values.
Here is my set-up:
I have an RG group, with a type of content as file, and the data source being the custom state. The custom state is a file-list
3.2 - Below is my HTML code - where i set the fields of current cell index and current cell file URL, i have even added code to ensure HTTPS is prepended
When i go to preview my app, nothing renders. Because it does not appear to replace the dynamic values. I know the custom state is all working, as i have set up a text element to display both file URL and also the Cell Index to make sure this is behaving as expected, however in the text element whilst it correctly identifies the file that has been uploaded, it does not prepend HTTPS
Bubble doesnt prepend https: for some reason. You should do it yourself, just put https: before the url.
And your second current cell's index doesnt look like a dynamic value but just a text. Maybe at some point while copy/pasting, you forgot it like a text. Because the first one seems to be working (stl-container-{{1}})
Your event listener script is a page load event (DOMContentLoaded). Since the script is looking for the appropriate containers (based off the ID prefix), there’s a chance that the RG elements are rendering after the script runs.
You don’t need the DOM load event and instead run the main code in a Run Javascript action (Toolbox plugin). The Run Javascript action should be in a WF that you are sure that the RG has been fully loaded.
It seems that Bubble is not correctly processing dynamic values in the HTML block. The issue might be related to how the data is passed to the three.js script.
What helped me in a similar situation:
Use console.log in the HTML to check if the URL and index values are actually being passed to the script.
Explicitly prepend https:// to the URL in the workflow, not just in the HTML code.
Use setTimeout() before rendering to ensure the values are available when three.js is called.
However, the issue might also be due to a delay in Bubble updating the values.