Opened 13 years ago

Closed 13 years ago

Last modified 11 years ago

#6633 closed Bug (invalid)

No events after setData

Reported by: Matthias Owned by:
Priority: Normal Milestone:
Component: General Version: 3.4.1
Keywords: Cc: karthick.ajk@…

Description

After you set the editor data via editor.setData(html) no more (key) events are fired on the body.

Example Code:

editor.document.getBody().on("keyup", function() {

alert("keyup event");

}); editor.setData("...");

After that, the keyup event will never be fired again. Maybe the editor creates a complete new body when calling setData (which implicitly removes the listeners)?

Change History (3)

comment:1 Changed 13 years ago by Alfonso Martínez de Lizarrondo

Resolution: invalid
Status: newclosed

Yes, a new document is created when setData is used and you must re-attach any listeners that you applied to the document or its contents.

comment:2 Changed 13 years ago by Karthik Jayapal

Cc: karthick.ajk@… added

But when do i re-attach the events? Is there an event fired after the setData is complete?

comment:3 Changed 11 years ago by bmulholland

To help future searchers: I found the answer at http://stackoverflow.com/questions/16054070/ckeditor-setdata-prevents-attaching-of-events-with-on-function

In particular, you attach on listeners the contentDom event, but you must also detach the listeners on contentDomUnload so that the new listeners work each time.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy