Script Tag not working on second load of page

21 views
Skip to first unread message

beckst...@gmail.com

unread,
Apr 13, 2019, 5:55:16 PM4/13/19
to intercooler-js
I am using intercooler and I have a script tag at the end of my html on each page. The issue I am having is that the javascript does not take affect on the second page swap.

If I do a full page reload it works, I think I am missing something fundamental to the way intercooler works and would love to be enlightened if so,

Thanks.

Anders Baumann

unread,
Apr 14, 2019, 12:24:43 AM4/14/19
to intercooler-js
Script tags which are dynamically added to the page via the DOM are executed by the browser. So it sounds like your script is not part of the content that you receive from the server when you perform the intercooler action. 

Did you look at the guidelines and examples? What scenario are you trying to solve?

beckst...@gmail.com

unread,
Apr 14, 2019, 12:28:03 AM4/14/19
to intercooler-js
On Sunday, April 14, 2019 at 12:24:43 AM UTC-4, Anders Baumann wrote:
> Script tags which are dynamically added to the page via the DOM are executed by the browser. So it sounds like your script is not part of the content that you receive from the server when you perform the intercooler action. 
>
>
> Did you look at the guidelines and examples? What scenario are you trying to solve?

I ended up figuring it out. Just need to wrap the script content in a function and call it on each page swap. Thanks.

Carson Gross

unread,
Apr 15, 2019, 12:03:01 AM4/15/19
to beckst...@gmail.com, intercooler-js
Good to hear.  By and large script tags should work as expected: the browsers execute them when they are swapped into the DOM.  It can get a little tricky with jQuery some times, but other than that it shouldn't be too different than "normal".

Cheers,
Carson
--
You received this message because you are subscribed to the Google Groups "intercooler-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intercooler-j...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages