Browse code

Update htmx lib

Benjamin Roth authored on08/03/2024 10:15:01
Showing1 changed files
... ...
@@ -5,12 +5,14 @@ htmx.defineExtension('disable-element', {
5 5
     onEvent: function (name, evt) {
6 6
         let elt = evt.detail.elt;
7 7
         let target = elt.getAttribute("hx-disable-element");
8
-        let targetElement = (target == "self") ? elt : document.querySelector(target);
8
+        let targetElements = (target == "self") ? [ elt ] : document.querySelectorAll(target);
9 9
 
10
-        if (name === "htmx:beforeRequest" && targetElement) {
11
-            targetElement.disabled = true;
12
-        } else if (name == "htmx:afterRequest" && targetElement) {
13
-            targetElement.disabled = false;
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
+            }
14 16
         }
15 17
     }
16 18
 });
17 19
\ No newline at end of file
Browse code

Initial htmx npm packages installation

Benjamin Roth authored on25/05/2023 09:52:13
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+"use strict";
2
+
3
+// Disable Submit Button
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 targetElement = (target == "self") ? elt : document.querySelector(target);
9
+
10
+        if (name === "htmx:beforeRequest" && targetElement) {
11
+            targetElement.disabled = true;
12
+        } else if (name == "htmx:afterRequest" && targetElement) {
13
+            targetElement.disabled = false;
14
+        }
15
+    }
16
+});
0 17
\ No newline at end of file