简体   繁体   中英

Get CKEDITOR id and value using event

CKEDITOR 4

$(document).ready(function(){
        CKEDITOR.on('instanceCreated', function(e) {
            e.editor.on('contentDom', function() {
                e.editor.document.on('keyup', function(event) {
                    //want current ckeditor id
                });
        });
        }); 
    });

I have more than one ckeditor and all are creating at run time. Is it possible to get ck editor's id and value if I have event object.

You didn't mention which version so I'm assuming 4.x. You could loop through the instances to find the document:

e.editor.document.on('keyup', function(event) {
    for (name in CKEDITOR.instances) {
        var instance = CKEDITOR.instances[name];
        if (instance.document == this) {
            alert('ID: ' + instance.id + '\nName: ' + instance.name + '\n' + instance.getData());
            break;
        }
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM