Search code examples
javascriptjqueryruby-on-railsckeditorruby-on-rails-5

Get all visible CKEditor instances


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?


Solution

  • I ended up checking the visibility of the closest div

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