1 | "use strict";
|
2 |
|
3 |
|
4 | htmx.defineExtension('disable-element', {
|
5 | onEvent: function (name, evt) {
|
6 | let elt = evt.detail.elt;
|
7 | let target = elt.getAttribute("hx-disable-element");
|
8 | let targetElements = (target == "self") ? [ elt ] : document.querySelectorAll(target);
|
9 |
|
10 | for (var i = 0; i < targetElements.length; i++) {
|
11 | if (name === "htmx:beforeRequest" && targetElements[i]) {
|
12 | targetElements[i].disabled = true;
|
13 | } else if (name == "htmx:afterRequest" && targetElements[i]) {
|
14 | targetElements[i].disabled = false;
|
15 | }
|
16 | }
|
17 | }
|
18 | }); |
\ | No newline at end of file |