最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get all visible CKEditor instances - Stack Overflow

programmeradmin1浏览0评论

It is possible to loop through all the CKEditor instances like:

for(var instanceName in CKEDITOR.instances) {
  ...
}

Some of the CKEditors are hidden in my case. So, how is it possible to loop through the visible CKEditors?

It is possible to loop through all the CKEditor instances like:

for(var instanceName in CKEDITOR.instances) {
  ...
}

Some of the CKEditors are hidden in my case. So, how is it possible to loop through the visible CKEditors?

Share Improve this question asked Aug 8, 2016 at 11:41 websterwebster 4,0326 gold badges41 silver badges61 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

I ended up checking the visibility of the closest div

for(var instanceName in CKEDITOR.instances) { 
  if($("#"+instanceName).closest(".form-group").is(':visible')){
     ...
  }
}

try with setTimeout(function(){},1000); as sometime one javascript instance is ongoing and by loop it is going to create another one so may b chances for nonworking. try your logic with setTimeout .it will work.

for(var instanceName in CKEDITOR.instances) { 
setTimeout(function(){ 
  if($("#"+instanceName).closest(".form-group").is(':visible')){
     ...## your code goes here
  }
}, 3000);
}

Try like this way...

Try this:

for (var instance in CKEDITOR.instances) {        
    if (CKEDITOR.instances.hasOwnProperty(instance)) {             
        if (CKEDITOR.instances[instance].closest(".wrapper").is(':visible')) {
            ...
        }         
    }
} 
发布评论

评论列表(0)

  1. 暂无评论