kendo-ui - 无法配置在没有工具栏的 div 元素上应用的剑道编辑器
问题描述
我在 div 元素上应用了剑道编辑器,而不是使用 textarea,因为它在 iPad 中会出现一些问题。现在,我不希望编辑器有工具栏来格式化文本。
我尝试将样式应用为 none & set tools 到一个空数组,但工具栏仍然出现,其中有一个可拖动的按钮。
<div id="targetdiv" contenteditable="true" style = "resize: none;width:
100%
!important; height:150px; max-height:150px;max-width: 100% !important;">
</div>
<script>
$("#targetdiv").kendoEditor({
tools: []});
</script>
工具栏在没有工具的情况下通过它初始化的编辑器出现,如下图所示。
方法1:(不工作)
<style>
.k-editor-toolbar
{
display:none;
}
</style>
方法2:(不工作)
$('.k-editor-toolbar').hide();
方法3:(部分有效)
添加了一个选择事件,但工具栏仍然会出现一瞬间然后消失。
$("#targetdiv").kendoEditor({
tools: [],
//Fires when the Editor selection has changed.
select: function (e) {
let editor = $("#targetdiv").data("kendoEditor");
editor.toolbar.hide();
});
解决方案
最后,
我必须订阅编辑器工具栏的打开事件并阻止其执行。这解决了我的问题。
let editor = $("#targetdiv").getKendoEditor();
editor.toolbar.window.bind("open", function (e) {
e.preventDefault();
});
推荐阅读
- python - 如何在 DJANGO 中查询包含值列表的 JSONField
- bash - bash + 如何将 bz 字符转换为从 1 开始的整数
- ios - 避免在 MKAnnotationView 中旋转标注
- php - 使用链接标签链接css文件在服务器中不起作用
- c# - 如何编辑现有查询?SQL server .Net Framework 中的搜索条件生成器
- python - 列表对象没有属性“应用”,即使它不是列表
- python - 我尝试获取 Post 的所有评论并在 NotfFaId 中添加用户,
- python - 出现错误 - “parse_genie:未安装精灵包。要安装,请运行‘pip install genie’。”
- php - 我想连接并显示来自 sql 数据库的两个表
- google-apps-script - 如何在 Google Apps 脚本中引用忙/闲菜单?