我正在尝试使用 htmx 实现发布请求,并使用 tinymce 实现富文本编辑器。
我的表格:
<!--<form method="POST"> {% csrf_token %}-->
<form onsubmit='copyContent()' method= "post" hx-post= "{% url 'forum:forum-detail' post.pk %}" hx-swap="innerHTML" hx-target = "#comment-list">
<div class="modal-body">
<div class="form-group">
<label for="threadTitle">Your Answer</label>
<textarea name="reply" class="form-control summernote" placeholder="Input your answer here"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" id="cancelForm">Cancel</button>
<button type="submit" class="btn btn-primary" name="btn-post-question">Post</button>
</div>
</form>
我得到的错误:
<ul class="errorlist"><li>reply<ul class="errorlist"><li>This field is required.</li></ul></li></ul>
当我使用 TinyMCE 的传统发布请求时,它工作得很好。
当我在没有 TinyMCE 的情况下使用 htmx 时,它的工作也很好。
就在我结合 htmx 和 TinyMCE 时,我得到了错误。
我的tinymce初始化:
tinymce.init({
selector: 'textarea',
body_id : "reply",
height: 200,
plugins: 'a11ychecker advcode casechange export formatpainter linkchecker autolink lists checklist media mediaembed pageembed permanentpen powerpaste table advtable tinycomments tinymcespellchecker image code',
toolbar: 'a11ycheck addcomment showcomments casechange checklist code export formatpainter pageembed permanentpen table image',
toolbar_mode: 'floating',
tinycomments_mode: 'embedded',
tinycomments_author: 'Author name',
});