I work on a module translation.
I have more than 100 textarea on one page. To increase the load I create an instance on click. When I quit the editor by clicking elsewhere, I want to update de textarea and remove the instance.
I do that but it doesn't work.
$('textarea').each(function(){
// Ajout de l'instance
$(this).click(function () {
//$(this).ckeditor(config_editor);
editor = CKEDITOR.replace(this,config_editor);
console.log(editor);
editor.focusout(function(e) {
if (e.editor.checkDirty()) console.log(e.editor.getData());
e.editor.destroy();
});
});
});
You can try like this
$('textarea').click(function () {
//$(this).ckeditor(config_editor);
console.log(this);
editor = CKEDITOR.replace(this,config_editor);
console.log(editor);
editor.on('blur', function(e){
if (e.editor.checkDirty()) console.log(e.editor.getData());
e.editor.destroy();
});
});
for dynamically added textarea
$(document).on('click','textarea',function(){
//above code
});
I paste the code of Man Programmer :
// Lancement de CKEDITOR
$('textarea').click(function () {
editor = CKEDITOR.replace(this,config_editor);
editor.on('blur', function(e){
e.editor.destroy();
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.