1

我有一个模糊功能附加到我的ckeditor,就像这样

editor = CKEDITOR.instances.fck;
editor.on("blur",function(e){
    alert("hello");
});

你跟我 ?

现在,当我单击 flash 按钮时,编辑器会模糊并显示警报。

如何阻止这种情况发生并且仍然在其他时间出现警报,例如当用户离开编辑器区域时

再次感谢

4

3 回答 3

6

只要我们正在研究黑客,这就是我喜欢用来解决这个问题的方法。关键是 CKE 使用 iFrames 作为其下拉类型控件(颜色选择器和背景颜色、字体大小、字体类型)

 editor.on("blur", function(e) {
  if ($(document.activeElement).get(0).tagName.toLowerCase() != "iframe") {
      // your code here for "real" blur event
  }
});
于 2012-11-02T18:55:08.780 回答
0

The blur event is firing when you click on a button like flash after the up click when the dialog is presented. The blur event that you want on happens right after mouse down outside the editor. This is dirty but by tracking the mouse state you can achieve your goal.

$(function() {
    var mouseState = 0;
    $(document).mousedown(function(){ mouseState = 1; });
    $(document).mouseup(  function(){ mouseState = 0; });

    var editor = CKEDITOR.instances.editor1;
    editor.on("blur", function(e) {
        if (mouseState == 1) console.log("blur");
    });
});
于 2010-04-08T20:47:01.290 回答
0

我现在也有这个问题。

我的解决方案是将编辑器包装在一个 holder 中,我们称它为 id="holder",并绑定此事件:

var isMouseOverEditor = false;
$('#holder').hover(function(){
  isMouseOverEditor = (e.type=='mouseenter' ? true : false);
});

稍后在编辑器的 on blur 事件中:

editor.on("blur", function(e) {
  if (!isMouseOverEditor) return;
  // your code here for "real" blur event
});

这不是最好的解决方案,但它是一个很好的解决方法,可以使用。似乎编辑器的模糊事件绑定到编辑器本身。这意味着当编辑区域模糊时,触发事件。

希望这可以帮助任何有这个问题的人。

于 2011-01-18T13:07:17.413 回答