Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scripts in the fragments loaded by unpoly are not executed

I load a fragment of the page using unpoly's up.replace method. On the page I have:

<div class="content"></div>
<script>
  console.log("content page is loaded");
  up.replace(".content", "/content/page", {history: false});
</script>

By the url /content/page I have html with the div of class "content":

<div class="content">
  <p>Some content</p>
  <div class="more-content"></div>
  <script>
    console.log("more content page is loaded");
    up.replace(".more-content", "/more/content/page", {history: false});
  </script>
</div>

And on the third page by url /more/content/page I have a div of class "more-content".

<div class="more-content"><p>Some more content</p></div>

I the content of both pages needs to be loaded but only the first one is. I see in chrome's inspector the tag script of the content page is present but it's not executed, there is no output in the console and the content of more/content page is absent. How to make the dynamically loaded script tags to be executed?

like image 489
AndreyKo Avatar asked Oct 27 '25 10:10

AndreyKo


1 Answers

Unpoly will not execute <script> tags in loaded fragments. You need to launch all your JavaScript from compilers.

like image 81
triskweline Avatar answered Oct 28 '25 22:10

triskweline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!