如何使用jQuery销毁内联编辑器

如何使用jQuery销毁内联编辑器,jquery,ckeditor,destroy,Jquery,Ckeditor,Destroy,假设这是我的代码: <div class="editor" contenteditable></div> // This is working for me $('.editor').click(function(){ $(this).ckeditor(); }); // This is the problem $('.editor').on('focusout', function(){ $(this).ckeditorDestroy(); // Wha

假设这是我的代码:

<div class="editor" contenteditable></div>

// This is working for me
$('.editor').click(function(){
   $(this).ckeditor();
});

// This is the problem
$('.editor').on('focusout', function(){
   $(this).ckeditorDestroy(); // What will destroy ckeditor?
});

//这对我有用
$('.editor')。单击(函数(){
$(this.ckeditor();
});
//这就是问题所在
$('.editor').on('focusout',function(){
$(this).ckeditorDestroy();//什么会破坏ckeditor?
});
我知道此函数不存在,但我没有发现任何正在工作的功能?

尝试执行以下操作:

$('.editor').on('focusout', function(){
   $(this).ckeditor(function(){
        this.destroy();
    });
});
HTML


使用事件而不是
focusout
或类似的,因为打开编辑器对话框并不意味着编辑器模糊,而在这种情况下可能会触发
focusout
。这样更安全

我是用ES6这样做的。对于ES5,交换
instance.attr(“title”)。包括(名称)
instance.attr(“title”).indexOf(名称)!=-1;

function disableCKEDITORInstance(instance) {
    var instance = $(instance);
    instance.removeClass("selected");
    instance.attr("contenteditable", "false");
    for(name in CKEDITOR.instances) {
        if (instance.attr("title").includes(name)){
            CKEDITOR.instances[name].destroy(true);
        }
    }
}

可能是你的复制品做了一些我想要的东西:“这个。ckeditor…这个销毁”。
CKEDITOR.disableAutoInline = true;

$( '.editor' ).click( function(){
    $( this ).ckeditor( function() {
        console.log( 'Instance ' + this.name + ' created' );
    }, {
        on: {
            blur: function( evt ) {
                console.log( 'Instance ' + this.name + ' destroyed' );
                this.destroy();
            }
        }
    } );
} );
function disableCKEDITORInstance(instance) {
    var instance = $(instance);
    instance.removeClass("selected");
    instance.attr("contenteditable", "false");
    for(name in CKEDITOR.instances) {
        if (instance.attr("title").includes(name)){
            CKEDITOR.instances[name].destroy(true);
        }
    }
}