Skip to content

Commit

Permalink
Update richtext values before htmx submits data
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sunnavy committed Jan 10, 2024
1 parent 184547d commit a4b1e79
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions share/static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit a4b1e79

Please sign in to comment.