From 068161e81723ed41d380f8a3508637e88bb8aab4 Mon Sep 17 00:00:00 2001 From: ssendev Date: Thu, 11 Jun 2020 17:24:35 +0200 Subject: [PATCH 1/2] fix hx-sse trigger in example --- www/attributes/hx-sse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/attributes/hx-sse.md b/www/attributes/hx-sse.md index 0b77e1d1..c9e95735 100644 --- a/www/attributes/hx-sse.md +++ b/www/attributes/hx-sse.md @@ -18,7 +18,7 @@ Here is an example: ```html
-
+
...
From 55a0fb51dd6d4e6da4fdc7422668b73f7f8f2f93 Mon Sep 17 00:00:00 2001 From: Luis Cortes Date: Thu, 11 Jun 2020 12:47:33 -0600 Subject: [PATCH 2/2] Fixed issue with xhr. --- src/ext/json-enc.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ext/json-enc.js b/src/ext/json-enc.js index 76ca75f8..eb76bdc0 100644 --- a/src/ext/json-enc.js +++ b/src/ext/json-enc.js @@ -1,7 +1,12 @@ htmx.defineExtension('json-enc', { + onEvent: function (name, evt) { + if (name === "configRequest.htmx") { + evt.detail.headers['Content-Type'] = "application/json"; + } + }, + encodeParameters : function(xhr, parameters, elt) { - xhr.setRequestHeader('Content-Type', 'application/json'); xhr.overrideMimeType('text/json'); return (JSON.stringify(parameters)); } -}); +}); \ No newline at end of file