Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document script loading issues with DynamicFrame #9

Open
danstewart opened this issue Jan 16, 2023 · 0 comments
Open

Document script loading issues with DynamicFrame #9

danstewart opened this issue Jan 16, 2023 · 0 comments

Comments

@danstewart
Copy link
Contributor

danstewart commented Jan 16, 2023

Scripts do not load synchronously.

Basic example:

<script src="https://cdn.jsdelivr.net/npm/filepond@4.30.4/dist/filepond.min.js" ></script>

<script>
    console.log("Hit inline script");    
    console.log(window.FilePond);
</script>

On a normal page this works fine, but within binder we cannot wait for the first script to load before firing the second one.


Solutions

  1. Load dependencies outside of the frame
  2. Use other events to tell when things are ready, eg:
 <script src="https://cdn.jsdelivr.net/npm/filepond@4.30.4/dist/filepond.min.js" ></script>

<script>
    console.log("Hit inline script");
    document.addEventListener("FilePond:loaded", () => {
        console.log("FilePond is ready");
        console.log(window.FilePond);
    });
</script>

Notes

I've tried various things to make this work but no luck.

We grab the HTML response for the frame then go recreate all the script tags so they actually load, but when we add the body to the DOM it seems each script loads async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant