Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

javascript - 识别ckeditor文本区域ID以进行模糊事件(Identify ckeditor textarea id for blur event)

I have plenty of textareas which act as a CKEDITOR 4 .

(我有很多文本区域可以充当CKEDITOR 4 。)

I'm trying to perform the AJAX request on each textarea by blur event.

(我正在尝试通过模糊事件在每个文本区域上执行AJAX请求。)

I know how to do the blur event.

(我知道如何进行blur事件。)

but the problem is how can I get the ckeditor instance (textarea id) to get the data.

(但是问题是我如何获取ckeditor实例(textarea id)来获取数据。)

I found this question in SO and I tried but it doesn't help me.

(我在SO中找到了这个问题,但我尝试了一下,但没有帮助。)

also I tried like below method but no luck This is how I'm making all the textareas into ckeditor

(我也尝试了下面的方法,但是没有运气,这就是我将所有文本区域制作成ckeditor的方式)

$("textarea").each(function(){
CKEDITOR.inline( this,{toolbar:[{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat','Undo' ] },{ name: 'paragraph', groups: [ 'list' ], items: [ 'NumberedList', 'BulletedList' ] }]})
})

This below portion works well for particular id

(以下部分适用于特定ID)

CKEDITOR.instances.releaset44.on('blur', function() { 
  alert("save fun")
});

above codes are inside the body onload function.

(以上代码位于body onload函数内部。)

below code is in outside of the onload func.

(下面的代码在onload函数的外部。)

please correct me if I'm wrong

(如果我错了请纠正我)

 var editors = CKEDITOR.instances;

    for (var x in editors) {
          if (editors[x]) {
            var thisName = editors[x].name;
            alert(thisName)
            if (editors[thisName]) {
              editors[thisName].on('blur', function (e) {
                var data = e.editor.getData();
              alert(data)
              });
            }
          }
        }
  ask by Aroon translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...