我在CKEdtor的iframe中设置了事件处理程序,如下所示:
Enum2::Value
效果很好,但是当我点击“来源”按钮时,它不再起作用(警报不起作用)。
有人可以帮帮我吗???答案 0 :(得分:0)
请使用以下代码:
var editor = CKEDITOR.replace( 'editor1', { });
editor.on("pluginsLoaded", function( event ) {
editor.on( 'contentDom', function( ) {
var editable = editor.editable();
editable.attachListener( editable, 'click', function( evt ) {
console.log('click' );
}, null, null, 10 );
} );
} );
如果您想在切换到源模式并返回时保持点击监听器,则需要使用contentDom
事件 - https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.editor-event-contentDom。
请注意,您应该将听众附加到editable
而不是iframe
,并且您不需要jQuery。