QuillJS不适用于textarea [英] QuillJS doesn't work with textarea

查看:112
本文介绍了QuillJS不适用于textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试在Django 1.10模板中的特定表单字段上使用QuillJS,如下所示:

I am trying to use QuillJS on a specific form field in my Django 1.10 template as follows:

<link href="https://cdn.quilljs.com/1.1.3/quill.snow.css" rel="stylesheet">

<script src="https://cdn.quilljs.com/1.1.3/quill.js"></script>
<!-- Initialize Quill editor -->
<script>
  var quill = new Quill('#id_text', {
    theme: 'snow'
  });
</script>

问题是Django将我要使用Quill的表单字段呈现为 textarea 而不是 div ,并且Quill似乎不起作用:应用于文本的任何效果都不会在视觉上注册或结果输出中,当我尝试编辑现有记录时,即使在 textarea 标签。

The problem is that Django renders the form field I want to use Quill on as a textarea instead of a div, and Quill doesn't seem to work on it: any effects applied to text don't register either visually or in the resulting output, and when I try to edit an existing record the initial text doesn't show up in the editor, even though it is there in the source HTML between the textarea tags.

这是一个已知问题,Quill无法与 textarea 一起使用吗?

Is it a known issue that Quill doesn't work with textarea or is there something else that could be wrong?

推荐答案

您可以将Quill与div结合使用并同步编辑器的内容( Delta ),其形式为隐藏的输入字段。

You can use Quill with a div and sync the editor's content(Delta) with a hidden input field in the form.

有一个鹅毛笔表单提交示例。

这篇关于QuillJS不适用于textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆