#12957 closed Bug (invalid)
Setdata disables click and hover event handlers
Reported by: | Sahana | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 4.0 |
Keywords: | Cc: |
Description
Once I setData on the html editor, I am unable to trigger click/hover event handlers on the html editor. If I comment the setData line, I can fire my click event handler easily. Once I uncomment the setData, click never fires oon the textarea.
Change History (2)
comment:1 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
click never fires oon the textarea.
CKEditor replaces textarea (sets it to display none) with HTML so assigning any listeners to textarea will have no effect.
Once I setData on the html editor, I am unable to trigger click/hover event handlers
Please do not attach listeners to HTML elements inside CKEditor content area becasue with each setData call you will have to attach them again (or better detach before setData and attach after setData).
Much better approach is assigning listener to editable
var editor = CKEDITOR.replace( 'editor1', {}); editor.on( 'contentDom', function( event ) { editor.editable().attachListener( editor.editable(), 'click', function( evt ){...} ); } );
It's not a bug. You need to bind all events according to the docs - http://docs.ckeditor.com/#!/api/CKEDITOR.editable-method-attachListener