1. 0
No votes yet

10263 downloads onchange

onChange

Get a notification (new event) whenever the content of CKEditor changes.

Releases

Plugin versions CKEditor versions
4.1 4.0

Version: 1.7 - Download

Show notes

Fixed compatibility with Source mode in CKEditor 4

unknown compatibilitycompatible

Version: 1.6 - Download

Show notes

Compatible with both CKEditor 3.6x and 4.0

unknown compatibilitycompatible
Log in to rate this plugin

Comments

Post a comment
  1. The content of this field is kept private and will not be shown publicly.
  1. MarcN's picture

    MarcN

    Reply

    I have a problem with this plugin in CKEditor 4.0. I get a JS error saying "Cannot call method 'on' of undefined" in line 131 which is this one here:
    editor.textarea.on( 'keydown', function( event )

    This happens whenever I open the source code view of the editor. Any ideas?

  2. Chloris's picture

    Chloris

    Reply

    I've found that "editor.textarea" is undefined in CKE Version 4. 


            // Detect changes in source mode
            editor.on( 'mode', function( e )
                {
                    if ( editor.mode != 'source' )
                        return;

                    editor.textarea.on( 'keydown', function( event )
                        {
                            // Do not capture CTRL hotkeys.
                            if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
                                somethingChanged();
                        });

                    editor.textarea.on( 'drop', somethingChanged);
                    editor.textarea.on( 'input', somethingChanged);
                    if (CKEDITOR.env.ie)
                    {
                        editor.textarea.on( 'cut', somethingChanged);
                        editor.textarea.on( 'paste', somethingChanged);
                    }
                });

    I had to quickly solve this issue using this fix instead. But other events like "drop, input, cut, paste" must be commented out.

                    $('#' + editor.container.$.id + ' textarea').on('keydown', function(event) {                    
                        if ( !event.ctrlKey && !event.metaKey ) somethingChanged();
                    });

     

  3. Sorry, I din't notice that because I made just some quick tests (but I had to fix that missing .textarea for the Configuration Helper plugin) and this page hasn't notified me about any comments.

    In the future it might be better to report problems in my blog as I'm sure that I get an email whenever something's posted there.

  4. With this plugin it's simple to trigger onchange event  with source textarea element, for validaton based on this event for example:

    $( 'textarea' ).ckeditor(function() { this.on( 'change', function(e) 
                { 
                    $("textarea[name='"+this.name+"']").change();
                }); });

  5. I have a small issue that I would want others to verify. WIth CKE 4.0.1 I do 

                    editor.on('change', function (ev) {
                        if (editor.checkDirty()) {
                            debug('onChange ToTrue');
                        } else {
                            debug('onChange ToFalse');
                        }
                    });

    If the magicline appears onChange toTrue is fired and when it dissappears toFalse is fired. If I don't have magicline and just type something in normally, onChange ToTrue does not happen! So I could type something, hit C-Z to undo and ToFalse fires. Then type something again and hit C-Z and then ToFalse happens again without a ToTrue inbetween. Any ideas?

    I'm trying to track changes while ignoring the magicline when I ran into this issue.

  6. ghgfh's picture

    ghgfh

    Reply

    jkjk

  7. scott12345's picture

    scott12345

    Reply

    I have a problem where if I enter text into any input field at all, any input field on the page, and this change event is triggered by the plug-in...