lea
March 10, 2023, 10:14pm
#1
Hello community
I have a custom code, which displays buttons that have different functions. My problem is that these buttons are displayed before the DOM, and before the softr content (which comes last).
I used this code thinking to delay their display a little bit, but it doesn’t change anything.
document.addEventListener("DOMContentLoaded", function() {
});
Does anyone have an idea for displaying the content of the HTML body at the same time as the softr fields ?
THANKS
artur
March 10, 2023, 10:32pm
#2
@lea is there any specific block you would like to use to anchor towards ? e.g. after this block is loaded then show mine?
lea
March 10, 2023, 10:50pm
#3
thx @artur in my case it is a ‘List details page with 3 column view’ but I also have other block in my list-details that could work
artur
March 10, 2023, 10:53pm
#4
This is how you wait for a block to load
window.addEventListener('block-loaded-table1', () => {
console.log('Block loaded');
});
replace table1 with your block name from settings
1 Like
lea
March 11, 2023, 8:29am
#5
Thanks @artur , it works a little better since I see this function triggering 100-300 milliseconds after the DOM is loaded.
However, the text content of the controls is still displayed a few tens or hundreds of miliseconds later. Is there no more reliable indicator?
artur
March 11, 2023, 12:23pm
#6
If you need to wait for data from airtable to be loaded to then use this
const onRecords = (e) => {
setTimeout(() => {
// The block finish rendering
// I may do some staff here.
}, 50);
};
window.addEventListener('get-record-table1', onRecords);
artur
March 13, 2023, 11:01pm
#7
@lea did this work for you ?
Dear all, sorry to interrupt, but I am curious if you are talking about the pain in my neck as well, here below are the indication.
If so, I would love to see how I can get rid of those preloaded image shown on the page before actually loading those content out.
lea
March 14, 2023, 6:48am
#9
not really, I’m still struggling with the code a bit, my buttons are still preloaded. but I will get there! Thanks artur