How to target all textarea elements for CKeditor Inline

ckeditor

Solution

You can use the "each" method in jquery to loop through each textarea and assign it the inline editor. I know this works, because I just implemented it in a work project. Like so:

$("textarea").each(function(){
    CKEDITOR.inline( this );
});

Problem

I am new to CKeditor, looking to have it setup on my page. I have quite an elaborate HTML form which contains about 13 textareas. I tried having 13 editors loaded on the page, which works but just messy and overwhelming for a user. I would like it if the editor's toolbar only shows if users click (focuses) on the textarea box and then hides the toolbar when they click away. I really like the inline editor they have which is pretty much what I an looking for but been struggling to get ckeditor to target and load on all my 13 text areas elements via inline. I've read so many sites but can't find a solution to my problem. I've tried the formula below, which should target elements via their class but seems like inline can't tolerate multiple instances at once. Would anyone know of a way to have inline working on all textareas elements on the page? This is the code I tried but its no good. ``` var elements = CKEDITOR.document.find( '.foo' ), i = 0, element; while ( ( element = elements.getItem( i++ ) ) { CKEDITOR.inline( element ); } ```

Original source