Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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 5 years ago by Piotrek Koszuliński

Resolution: invalid
Status: newclosed

It's not a bug. You need to bind all events according to the docs - http://docs.ckeditor.com/#!/api/CKEDITOR.editable-method-attachListener

comment:2 Changed 5 years ago by Jakub Ś

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 ){...} );
} );
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy