簡體   English   中英

使用事件獲取CKEDITOR ID和值

[英]Get CKEDITOR id and value using event

編輯器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
                });
        });
        }); 
    });

我有一個以上的ckeditor,並且都在運行時創建。 如果我有事件對象,是否可以獲取ck編輯器的ID和值。

您沒有提到哪個版本,所以我假設使用4.x。 您可以遍歷實例來查找文檔:

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;
        }
    }
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM