当我选择工具栏下拉菜单时,我的CKEditor实例正在获取“模糊”事件 [英] My CKEditor instance is getting the 'blur' event when I select a Toolbar dropdown

查看:187
本文介绍了当我选择工具栏下拉菜单时,我的CKEditor实例正在获取“模糊”事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面有一个textarea,它是一个CKEditor实例。当用户离开文本区域时,内容应保存。我遇到的问题是,当我尝试从工具栏中选择一个下拉项目(例如,如果我突出显示一个区域的文本,然后尝试应用一个格式从下拉列表中)时触发'blur'事件,所以如果我使用这个功能,内容保存(在应用样式之前),然后编辑器被销毁。



我的代码如下:

  //最初,colName是一个变量,它存储正在编辑的列的名称
// textarea id是editText_colName
$ ('#editText_'+ colName).ckeditor({
toolbar:'Basic',
format_tags:'h1; h2; h3; p',
resize_enabled:false
} );
var editor = $('#editText_'+ colName).ckeditorGet();
editor.on('blur',function(){
//获取文本编辑器的内容,并保存
var data = $('#editText_'+ colName).val ;
// ...保存数据...
// ...成功时,执行以下操作
editor.destroy();
$(' #editText_'+ colName).remove();
});

如何确保模糊功能仅在用户离开编辑器时才会到达,当他们从工具栏中选择一个菜单?



谢谢!

解决方案

>我假设你使用CKEditor 3.6.x.你观察到的是一个错误。它已在 CKEditor 4测试版中修复。您还可以查看最新的每夜构建,看看它现在是否正常工作。

$ b $对不起,我们在做最好的;)


My page has a textarea which is a CKEditor instance. When the user leaves the textarea, the content should save. The problem I'm having is that the 'blur' event is being triggered when I try to select a dropdown item from the toolbar (eg if I highlight an area of text and then try to apply a format from the dropdown), so if I use this functionality, the content saves (before the style is applied) and then the editor is destroyed.

My code is as follows:

// Initially, colName is a variable which stores the name of the column being edited
// The textarea id is editText_colName
$('#editText_' + colName).ckeditor({
            toolbar : 'Basic',
            format_tags : 'h1;h2;h3;p',
            resize_enabled : false
});
var editor = $('#editText_' + colName).ckeditorGet();
editor.on('blur', function() {
    // Get content of text editor, and save
    var data = $('#editText_' + colName).val();
    // ... save data ...
    // ... on success, do the following ...
    editor.destroy();
    $('#editText_' + colName).remove();
});

How can I make sure that the blur function is only reached when the user leaves the editor, and not when they select a menu from the toolbar?

Thanks!

解决方案

I assume that you're using CKEditor 3.6.x. What you're observing is actually a bug. It has been fixed in CKEditor 4 beta. You can also check the latest nightly build to see that it's working now.

Sorry for that, we're doing our best ;)

这篇关于当我选择工具栏下拉菜单时,我的CKEditor实例正在获取“模糊”事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆