diff --git a/www/ftui/components/element.component.js b/www/ftui/components/element.component.js index 5c18edb1..7890f751 100755 --- a/www/ftui/components/element.component.js +++ b/www/ftui/components/element.component.js @@ -32,9 +32,12 @@ export class FtuiElement extends HTMLElement { this.createShadowRoot(this.template()); } - if (window.ftuiApp) { - ftuiApp.attachBinding(this); - } + // solution adapted from the very useful thread https://stackoverflow.com/questions/7307983/while-variable-is-not-defined-wait + (async () => { + while (typeof window.ftuiApp === 'undefined') await new Promise(resolve => setTimeout(resolve, 2000)); + if (typeof window.ftuiApp === 'object') + window.ftuiApp.attachBinding(this); + })(); } createShadowRoot(content) {