#Modal won't load scripts

1 messages · Page 1 of 1 (latest)

stoic root
#

I am loading an HTML as a Modal and it has its own JavaScript file, and a couple libraries I am using calling them with CDN, but none of the scripts are loading only the HTML and CSS.

If someone know how can I load the scripts, I'll appreciate it, sorry if the explanation is not the best.

JS of the main html

cardPickerBtn.addEventListener('click', () => {
vpModal.style.display = 'block'
document.getElementById('slider-main').style.display = 'none'

const request = new XMLHttpRequest();
request.open('GET', 'page 8(cards).html');
request.onload = function() {
  vpModal.innerHTML = request.response;
};
request.send();

});

Modal HTML scripts
<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.min.js"></script>
<script src="page 8(masonery).js" type="module" async></script>

versed wasp
#

Hello there, seems like the closing tag for <script> is missing. Could you try this:

<script src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script src="https://unpkg.com/imagesloaded@5/imagesloaded.pkgd.min.js"></script>
stoic root
civic island
#

You can't just include a <script> tag in the HTML that's being loaded dynamically via innerHTML... There's more to it than that I'm afraid. Here's an article which explains a way to do it.

https://www.tutorialspoint.com/can-scripts-be-inserted-with-innerhtml