diff options
author | carson <carson@leaddyno.com> | 2020-09-18 08:59:51 -0600 |
---|---|---|
committer | carson <carson@leaddyno.com> | 2020-09-18 08:59:51 -0600 |
commit | 4e15653adba76fb297da0a021a80ee8187904e5b (patch) | |
tree | f1d190f9cb5625fb05e8e20cef0c833e1f718300 /www/test/0.1.1/src/ext/include-vals.js | |
parent | c218853011cf96550b21981b164cf137afb074c1 (diff) | |
download | htmx-0.1.1.tar.gz htmx-0.1.1.zip |
0.1.1 release - fix double event dispatch bugv0.1.1
Diffstat (limited to 'www/test/0.1.1/src/ext/include-vals.js')
-rw-r--r-- | www/test/0.1.1/src/ext/include-vals.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/www/test/0.1.1/src/ext/include-vals.js b/www/test/0.1.1/src/ext/include-vals.js new file mode 100644 index 00000000..d8f5ce4f --- /dev/null +++ b/www/test/0.1.1/src/ext/include-vals.js @@ -0,0 +1,24 @@ +(function(){ + + function mergeObjects(obj1, obj2) { + for (var key in obj2) { + if (obj2.hasOwnProperty(key)) { + obj1[key] = obj2[key]; + } + } + return obj1; + } + + htmx.defineExtension('include-vals', { + onEvent: function (name, evt) { + if (name === "htmx:configRequest") { + var includeValsElt = htmx.closest(evt.detail.elt, "[include-vals],[data-include-vals]"); + if (includeValsElt) { + var includeVals = includeValsElt.getAttribute("include-vals") || includeValsElt.getAttribute("data-include-vals"); + var valuesToInclude = eval("({" + includeVals + "})"); + mergeObjects(evt.detail.parameters, valuesToInclude); + } + } + } + }); +})(); |