javascriptjquerytextareajodit

multi textarea by jodit


I have more than 15 editors and want to display them on one page (HTML/CSS/JS). This Jodit only works with one editor, but it does not work with more than one editor. I want all editors to work.

See this sample code : Fiddle

<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>

...

<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
<textarea class="email_content"></textarea>
var editor = new Jodit(".email_content", {
  "toolbarButtonSize": "small",
  "enter": "DIV",
  "buttons": "undo,redo,|,bold,strikethrough,underline,italic,,,,,,,,,,,,,,,,align,"
});

Is there a code that works in more than one editor?


Solution

  • var editors = [].slice.call(document.querySelectorAll('.editor'));
    editors.forEach(function (textarea) {
    var editor = new Jodit(textarea, {
      "toolbarButtonSize": "small",
      "enter": "DIV",
      "buttons": "undo,redo,|,bold,strikethrough,underline,italic,,,,,,,,,,,,,,,,align,"
        });
    });