Hi @ruenel,
Thanks for explaining the loading behaviour of the page. I have since found a way to delay the loading of the embedded form until the modal’s toggle is clicked, so the page loads normally again.
Just in case it is of help to anyone else using the ResDiary table booking system, here is the solution:
MODAL
To be able to add the Component more than once on a page, we need to get a unique ID. I did this by adding a parameter to the Component. (The Component already has a number of parameters, so this is added at the end). The parameter’s value is:
resmodal-{{ random.uniqueid }}
Then in the Modal’s Customize tab, I added the following dynamic content to bring through the parameter’s value into both Toggle Hash and ID:
{{dc:p:cwDynamicIds.modalId}}
RAW CONTENT ELEMENT
This is placed inside the modal with the following code:
<div class="resdiary-frame" data-src="https://booking.resdiary.com/widget/Standard/YOURUNIQUE/LINK?includeJquery=true" style="width:100%; max-width:600px; height:550px; margin:auto; display:block;"></div>
COMPONENT JS
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.x-anchor-toggle').forEach(function (toggleBtn) {
toggleBtn.addEventListener('click', function () {
// Find the corresponding modal container for this toggle
// Usually toggleBtn has aria-controls or href pointing to modal id
const modalSelector = toggleBtn.getAttribute('href') || toggleBtn.getAttribute('aria-controls');
if (!modalSelector) return;
// Remove any hash (#) from selector if present
const modalId = modalSelector.replace(/^#/, '');
const modal = document.getElementById(modalId);
if (!modal) return;
// Find iframe container inside this modal
const iframeContainer = modal.querySelector('.resdiary-frame');
if (iframeContainer && !iframeContainer.querySelector('iframe')) {
const src = iframeContainer.dataset.src;
const iframe = document.createElement('iframe');
iframe.src = src;
iframe.style.width = '100%';
iframe.style.maxWidth = '600px';
iframe.style.height = '550px';
iframe.style.border = '0';
iframe.style.margin = 'auto';
iframe.style.display = 'block';
iframe.loading = 'eager';
iframe.allowTransparency = true;
iframeContainer.appendChild(iframe);
}
});
});
});
Thanks,
Christopher