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,24 @@
1
+(function(){
2
+
3
+    function mergeObjects(obj1, obj2) {
4
+        for (var key in obj2) {
5
+            if (obj2.hasOwnProperty(key)) {
6
+                obj1[key] = obj2[key];
7
+            }
8
+        }
9
+        return obj1;
10
+    }
11
+
12
+    htmx.defineExtension('include-vals', {
13
+        onEvent: function (name, evt) {
14
+            if (name === "htmx:configRequest") {
15
+                var includeValsElt = htmx.closest(evt.detail.elt, "[include-vals],[data-include-vals]");
16
+                if (includeValsElt) {
17
+                    var includeVals = includeValsElt.getAttribute("include-vals") || includeValsElt.getAttribute("data-include-vals");
18
+                    var valuesToInclude = eval("({" + includeVals + "})");
19
+                    mergeObjects(evt.detail.parameters, valuesToInclude);
20
+                }
21
+            }
22
+        }
23
+    });
24
+})();