假设这是我的代码:
<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?
});
我知道这个功能不存在,但我没有发现什么在起作用?
HTML
<div contenteditable="true" class="editor">Editor 1!</div>
<div contenteditable="true" class="editor">Editor 2!</div>
JS
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();
}
}
} );
} );
Use 编辑器#blur http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-blur事件而不是focusout
或类似的,因为即打开编辑器对话框并不意味着编辑器模糊,而focusout
在这种情况下可能会被解雇。这样更安全。有关 jQuery 适配器的更多信息 http://docs.ckeditor.com/#!/guide/dev_jquery.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)