首页 > 解决方案 > 单击编辑器上的工具栏按钮时,不将焦点放在 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没有获得焦点然后被模糊的最佳方法是什么。

标签: javascriptjqueryfroala

解决方案


在 Froala 富文本编辑器获得焦点后触发。

new FroalaEditor('.selector', {
  events: {
    'focus': function () {
      // Do something here.
      // this is the editor instance.
      console.log(this);
    })
  }
});

推荐阅读