javascript - 单击编辑器上的工具栏按钮时,不将焦点放在 Froala 编辑器上的编程方法是什么。 $el (textarea)
问题描述
目前我很难理解,Froala
单击工具栏按钮时哪种方式最好不要将焦点集中在编辑器上?
我试图通过事件访问编辑器,但我无法让它工作,我不确定这是正确的选择
new FroalaEditor(".froala_editor", {
events: {
'toolbar.focusEditor': function () {
alert("hello")
console.log(this);
}
}
});
我们有editor.button.bindCommands()
,但我也不明白。
我可以去工作的是
var editor = new FroalaEditor(".froala_editor", {}, function () {
$("button#moreText-1").click(function() {
editor.$el.blur()
});
});
现在,当我单击moreText按钮时,似乎现在没有焦点在编辑器上,插入符号也没有显示。
但是有没有更多的api类型的方法来做到这一点。例如,必须触发一个事件以将textarea聚焦在点击上,那么确保textarea没有获得焦点然后被模糊的最佳方法是什么。
解决方案
在 Froala 富文本编辑器获得焦点后触发。
new FroalaEditor('.selector', {
events: {
'focus': function () {
// Do something here.
// this is the editor instance.
console.log(this);
})
}
});
推荐阅读
- fortran - iso_fortran_env 种类值不是编译时常量
- ios - flutter firebase_admob 0.8.0+3 iOS build FAILED,android 工作正常
- javascript - 使用javascript重命名输入中的文本(每点更改空间)
- listview - 颤振中无线电列表的问题
- php - PHP 将外部 API 请求总数限制为每秒 8 次
- visual-studio - 使用 Visual Studio Docker 撰写支持运行测试
- django - 如何从类 Account 中获取图像,并在 PostListView 中使用它?
- sql - 如何在 SQL Server 中组合名称相似但值不同的不同表中的两列
- python - maya 中的警告:“无法分配”,为什么?
- unity3d - 项目设置中的 Time.FixedTimeStep 已禁用