From a4b1e794386dd9194721c81f638076b99a0b0d52 Mon Sep 17 00:00:00 2001 From: sunnavy Date: Wed, 10 Jan 2024 17:10:21 -0500 Subject: [PATCH] Update richtext values before htmx submits data CKEditor automatically updates corresponding textarea values on form submit, but htmx collects data before that, which causes submitted textarea values to be outdated. This commit explicitly updates textarea values before htmx submits, to get around the issue. --- share/static/js/util.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/share/static/js/util.js b/share/static/js/util.js index 352fa09564..c078f5fda0 100644 --- a/share/static/js/util.js +++ b/share/static/js/util.js @@ -1021,6 +1021,14 @@ document.addEventListener("htmx:load", function() { form.addClass('rt-form-submitted'); }); }); + + document.body.addEventListener('htmx:configRequest', function(evt) { + for ( const param in evt.detail.parameters ) { + if ( evt.detail.parameters[param + 'Type'] === 'text/html' && CKEDITOR.instances[param] ) { + evt.detail.parameters[param] = CKEDITOR.instances[param].getData(); + } + } + }); }); function filterSearchResults () {