Note that there are some explanatory texts on larger screens.

plurals
  1. POCall CKEditor by class
    primarykey
    data
    text
    <p>I need to call multiple instances of CKEditor automatically...actually I use the function:</p> <pre><code>CKEDITOR.replace( 'editor1'); </code></pre> <p>Where "editor1" is the id name of the div where I want show my CKEditor.</p> <p>I'm using jQuery to automate this process and I need to use the "class" tag instead the id.</p> <p>In particular i have this html:</p> <pre><code>&lt;div class="CKEditor"&gt; &lt;div class="text"&gt; mytext &lt;/div&gt; &lt;p style="text-align:center" class="buttons"&gt; &lt;input type="button" value="edit" class="button_edit"&gt; &lt;input type="button" value="preview" class="button_preview" style="display:none"&gt; &lt;/p&gt; &lt;div class="editor" &gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and this jQuery script:</p> <pre><code>$(function() { $('.CKEditor').each(function() { var __main = $(this); var __buttons = __main.children('.buttons'); var __text = __main.children(".text"); var editor; __buttons.children('.button_edit').click(function() { __text.hide(); if (editor) return; editor = CKEDITOR.replace("editor"); editor.setData(__text.html()); if(editor) { __buttons.children('.button_edit').hide(); __buttons.children('.button_preview').show(); } }); __buttons.children('.button_preview').click(function() { __text.show(); __text.html(editor.getData()); if ( !editor ) return; editor.destroy(); editor = null; __buttons.children('.button_edit').show(); __buttons.children('.button_preview').hide(); __main.children("#editor").html(""); }); }); }); </code></pre> <p>Is it possible without modify the source of CKEDITOR?</p> <hr> <p><strong>EDIT</strong></p> <p>I found the solution:</p> <p>1) The html become:</p> <pre><code>&lt;div class="editor" id="edt1"&gt;&lt;/div&gt; </code></pre> <p>2) In the JQuery:</p> <pre><code>var __editorName = __main.children('.editor').attr('id'); </code></pre> <p>and i call CKEditor with:</p> <pre><code>editor = CKEDITOR.replace(__editorName); </code></pre> <p>=) =)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload