jsf - 在 p:textEditor 中添加或附加文本
问题描述
我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);
推荐阅读
- javascript - 为什么 this.setState 不更新句柄删除数据?
- c - 从文件中读取一个单词并将其旁边的值存储在 c 中
- r - 在 R 中将 SpatialCollections 转换为 SpatialPolygonsDataFrame
- database - 在 SQLite 中选择月份范围
- python - 没有名为“object_detection”的模块
- javascript - 编程到 2D Array 复杂对齐
- android - 当片段更改时计时器重置,add() 将片段堆叠在一起
- java - 在枚举类中,如何将值转换为日期?
- javascript - 选择相同类型元素的每第 n 个,但不在同一个父元素中
- wordpress - 如何通过 ACF 字段过滤 BuddyPress 成员循环?