How to use ckeditor together with javascript

Asked

Viewed 144 times

0

I’m trying to activate a function within the text area of the ckeditor like onclick, onload, onkeypress or onkeyup, it works perfectly`te in "normal" textareas but when I implement the ckeditor it "blocks" it

echo"<textarea   id='editor1'  name='descricao' class='form-control' rows='10' required >$descricao</textarea>"; ?>

CKEDITOR.replace( 'editor1' );

$(Document). ready(Function(){ $.fn.modal.Constructor.prototype. _enforceFocus = Function(){};

});

1 answer

0


You can use the event keyup, for example, in this way:

var editor = CKEDITOR.replace('editor1');
editor.on('pluginsLoaded', function(){
   editor.on('contentDom', function(){
      var editable = editor.editable();                   
      editable.on('keyup', function(){ 
         // fazer algo aqui com keyup
      });
   });
});

It is always good to assign the Ckeditor instance to a variable to use as a reference. In this case, assign the variable editor.

  • I couldn’t make an Alert echo"<textarea id='editor1' name='Descricao' class='form-control' Rows='10' required >$Descricao</textarea>"; ? > <script> CKEDITOR.replace( 'editor1' ); var editor = CKEDITOR.replace('editor1'); editor.on('pluginsLoaded', Function(){ editor.on('contentDom', Function(){ var Editable = editor.Editable(); Editable.on('keyup', Function(){ Alert('123'); }); }); }); $(Document). ready(Function(){ $.fn.modal.Constructor.prototype._enforceFocus = Function(){}; }); </script>

  • Could you help me?

  • You put CKEDITOR.replace( 'editor1' ); twice. Delete the first and leave only the var editor = CKEDITOR.replace('editor1');.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.