我正在使用CKEditor 4但是当我将keyup
事件应用于它时,它无效。代码是:
HTML code:
<div class="col-md-9">
<div class="wc" id="wcso"></div>
<div id="storyOutlineCircle1" class="badge badge-success round storyOutlineCircleClass" style="position: absolute;right:30px;bottom:0px;">100</div>
<textarea id="storyOutline" rows="5" class="form-control" name="labinputstory" placeholder="Story Outline" required></textarea>
</div>
JS代码:
<script>
var e = CKEditor.instances['labinputstory']
e.on( 'keyup', function( event ) {
alert( e.getData() );
});
</script>
答案 0 :(得分:0)
CKEditor只有一个key event。如果您希望使用keyUp
,则需要将其附加到编辑editable
,如下所示:
var editor = CKEDITOR.replace( 'editor1', { /*editor instance configuration goes here*/ });
editor.on( "pluginsLoaded", function( event ){
editor.on( 'contentDom', function( evt ) {
var editable = editor.editable();
editable.attachListener( editable, 'keyup', function( e ) {
var keyCode = e.data.getKeystroke();
// if ( keyCode == ... )
});
});
});