Ticket #6633 (closed Bug: invalid)

Opened 5 years ago

Last modified 2 years ago

No events after setData

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


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

comment:1 Changed 5 years ago by alfonsoml

  • Status changed from new to closed
  • Resolution set to invalid

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 4 years ago by karthikj

  • 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 2 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 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy