fix: img-preload doesn't support data prefix + running cursor fix on load doesn't work

This commit is contained in:
overflowerror 2024-08-02 22:01:21 +02:00
parent 27ac8195b3
commit be991b99fc
2 changed files with 7 additions and 2 deletions

View file

@ -4,7 +4,12 @@ console.log("module loaded");
htmx.defineExtension('img-preload', {
onEvent: (name, event) => {
if ((event?.target?.getAttribute("hx-ext") ?? "") !== "img-preload") {
if (
(
event?.target?.getAttribute("hx-ext") ??
event?.target?.getAttribute("data-hx-ext" ?? "")
) !== "img-preload"
) {
return;
}

View file

@ -10,7 +10,7 @@
<input type="hidden" name="csrfToken" value="<?= $csrfToken ?>">
<h2><?= $mob["name"]; ?></h2>
<img alt="<?= $mob["name"]; ?>" src="/images/mobs/<?= $mob["image"] ?? "_placeholder.png"; ?>">
<script>document.getElementById("form-<?= $side ?>").style.cursor = "pointer";</script>
<script>setTimeout(() => { document.getElementById("form-<?= $side ?>").style.cursor = "pointer"; }, 1);</script>
<noscript><input class="fallback" type="submit" value="<?= $mob["name"]; ?>"></noscript>
</form>
</div>