ckeditor

CKEditor Inlineditor - Select by class instead of ID


So I have a page with several textareas for a custom form I made. I am able to target an individual textarea by it's ID but I would like to know if theres an easy way to have the CKeditor inline target all textareas elements or have editor select elements by their class instead. At the moment I have setup ID for each other but they are each unique, trying to figure out the best aproach but im not good with javascript and would like some assistance with this.

Current code:
<script>
CKEDITOR.inline( 'ID');
</script>

Looking for a code that would target all text areas or at lease target class instead of IDs.


Solution

  • Use CKEDITOR.document.find:

    var elements = CKEDITOR.document.find( '.foo' ),
        i = 0,
        element;
    
    while ( ( element = elements.getItem( i++ ) ) ) {
        CKEDITOR.inline( element );
    }
    

    You can also use the official jQuery adapter:

    $( '.foo' ).ckeditor( function() { 
        // Callback function code.
    }, { 
        // Config options here
    } );