ripe-action-67367
10/22/2022, 10:13 AMoverflow-hidden
(or some other class) when opening this modalripe-action-67367
10/22/2022, 10:13 AMripe-action-67367
10/22/2022, 10:13 AMripe-action-67367
10/22/2022, 10:17 AMripe-action-67367
10/22/2022, 10:17 AMripe-action-67367
10/22/2022, 10:18 AMmysterious-toddler-20573
10/22/2022, 2:24 PMbitter-machine-55943
10/22/2022, 3:41 PMhead-support
extension. When a <script>
tag gets merged into the <head>
, it executes the javascript as expected. But if I do it a second time, the javascript doesn’t execute, presumably because it’s already in the <head>
tag. That makes sense. But is there a way to get the javascript to run each time, the same way that if you’re clicking links between vanilla HTML pages, the javascript for that page will run each time? Or should I try something like Alpine’s x-init
to manually call whatever needs to be called each time that new chunk of HTML is swapped in? Or, is this just not a good idea to use hx-get
with head-support
to handle routing between pages?bitter-machine-55943
10/22/2022, 5:04 PMthankful-computer-7658
10/22/2022, 5:08 PMmysterious-toddler-20573
10/22/2022, 6:36 PMmysterious-toddler-20573
10/22/2022, 6:36 PMsrc
script tag, no?mysterious-toddler-20573
10/22/2022, 6:36 PMgorgeous-airport-54386
10/22/2022, 6:37 PMbitter-machine-55943
10/22/2022, 6:59 PMbitter-machine-55943
10/22/2022, 7:20 PMhtmx:afterSwap
event to call a javascript function? Or can hyperscript handle?gorgeous-airport-54386
10/22/2022, 7:21 PMbrainy-ice-92385
10/23/2022, 12:08 AMhead-support
having a pattern for re-triggering the code makes more sense.brainy-ice-92385
10/23/2022, 12:11 AMpreserve
. Instead of never swapping, you want it to always swap, right? So maybe the attribute is spoil
.mysterious-toddler-20573
10/23/2022, 11:16 AMmysterious-toddler-20573
10/23/2022, 11:18 AMhtml
<script hx-head="append" src="/whatever.js"><script/>
<div>Foo</div>
wouldn't require an enclosing head tag.
You could also hoist the hx-head
attribute to make all the elements, for example, appended:
html
<head hx-head="appendIfAbsent">
<script ...>
...
</head>
green-ram-18435
10/23/2022, 12:03 PMhundreds-dusk-97323
10/23/2022, 12:54 PMmysterious-toddler-20573
10/23/2022, 2:08 PMmysterious-toddler-20573
10/23/2022, 2:08 PMmysterious-toddler-20573
10/23/2022, 2:09 PMmysterious-toddler-20573
10/23/2022, 2:09 PMbitter-machine-55943
10/23/2022, 2:44 PM<head>
need different treatment? Or does it make sense to just expand the scope of HTMX beyond <body>
?
* I can get javascript to run from a new HTML chunk after it’s swapped in, but only using head-support
so the <script>
is present. Then, using onload
I can call refreshMe()
from the .js
file, but the first time that chunk of HTML is swapped in, the javascript runs twice.
* Possible downside of my existing approach: As I switch from page to page, more <script>
tags get added to <head>
without being removed. Not a huge deal, but if I had 100 pages that might start to cause some issue.
* As a general case, this is just swapping multiple chunks of HTML, with multiple targets, possibly with multiple merge algorithms, right?
* So should the path be: (1) create the generally applicable tool that enables <head>
to be treated like any other tag? Or (2) is that the DRY approach with too much magic, and the point would be to add some sugar so it’s more LOB and explicit?mysterious-toddler-20573
10/23/2022, 2:46 PMmysterious-toddler-20573
10/23/2022, 2:46 PM