Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#11602 closed Bug (invalid)

onchange event does not fire for CKEditor textarea input elements.

Reported by: Daryl H. Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

My application uses onchange="fldchanged();". It does not fire. Tested on IE and FireFox.

Attachments (1)

onchange-example.html (7.2 KB) - added by Daryl H. 5 years ago.
test to see if onchange event fires

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by Daryl H.

Attachment: onchange-example.html added

test to see if onchange event fires

comment:1 Changed 5 years ago by Daryl H.

Keywords: onchange added

comment:2 Changed 5 years ago by Piotrek Koszuliński

Keywords: onchange removed
Resolution: invalid
Status: newclosed
Version: 4.3

CKEditor does not use textarea for editing. The textarea is replaced by CKEditor. Therefore, doing anything with that replaced textarea won't give any results. The only thing that is done with textarea is updating it with editor's data before submitting form, so the data is submitted with the form.

If you want to listen on changes in CKEditor, then use this event http://docs.ckeditor.com/#!/api/CKEDITOR.editor-event-change

comment:3 Changed 5 years ago by Daryl H.

Could't you fire the change event manually upon replace? ie,

if (savedtextarea.onchange)
    savedtextarea.onchange();

Last edited 5 years ago by Daryl H. (previous) (diff)

comment:4 Changed 5 years ago by Piotrek Koszuliński

We don't find this justified. CKEditor is not trying to mimic textarea. It uses it only for data source.

comment:5 Changed 5 years ago by Daryl H.

Not to sound too pedantic, but shouldn't you be striving to emulate the entire functionality of the component you are trying to replace?

I looked at the link you provided, but it did not show examples on how to hook up the event. It would help if you could please provide a snipit of code to facilitate this. thanks.

comment:6 Changed 5 years ago by Piotrek Koszuliński

CKEditor is not trying to replace anything. Developer is doing that using CKEditor. That developer has full control over his website and can add a listener to the editor instance instead of adding it to textarea which, as I wrote earlier, is only a source of data loaded to CKEditor and submitted with a form. Moreover, there are hundreds of events, methods and properties on textarea or related to it. Editor cannot emulate most of them, so it's not even trying to do that.

This is more or less how emulation would have to look like:

editor.on( 'blur', function() {
    if ( editor.checkDirty() ) {
        editor.updateElement();
        textarea.onchange();
        editor.resetDirty();
    }
} );
Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy