我有 p:textEditor
像下面这样
<p:textEditor
id="editor"
widgetVar="editor"
value="#{xxxController.editorText}"
height="300"
placeholder="Enter your content"
toolbarVisible="false"/>
使用以下命令按钮将值添加/附加到 p:textEditor
<p:commandButton onclick="insertTag('[myValue]')" value="myValue" type="button" />
JavaScript
<script>
function insertTag( t )
{
PF( 'editor' ).insertText( t ) ;
}
</script>
但我得到 SCRIPT5007: Unable to get property 'insertText' of undefined or null reference
当我尝试单击 <p:commandButton
时.那么我们如何使用 widgetVar 或 JavaScript 将文本插入/附加到
p:textEditor
?版本详情
JSF 2.2,
PrimeFaces 6.2
最佳答案
你需要这样做......一旦你有了小部件,“编辑器”变量就是 QuillJS 对象。
PF('editor').editor.insertText(0, 'Hello', 'bold', true);
见:https://quilljs.com/docs/api/#inserttext见:https://quilljs.com/docs/api/#getlength
关于jsf - 在 p :textEditor 中添加或附加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62593793/