skip to Main Content
<div>
<textarea class="input-area additional" name="research_projects[]" placeholder="Project Details" spellcheck="false"></textarea>
</div>
<div>
<textarea class="input-area additional" name="research_projects[]" placeholder="Project Details" spellcheck="false"></textarea>
</div>

These are 2 textareas with identical name research_projects[ ]. And it is dynamic also, multiple of those textareas can be added. So how can I add ckeditor to all those textareas.

2

Answers


  1. Give them different IDs and do

    document.querySelectorAll("[name^=research_projects]")
      .forEach(elem => CKEDITOR.replace(elem.id));
    
    Login or Signup to reply.
  2. I have faced the same issue for submitting the form with add more button and the dynamic jquery content.
    CKEditor maybe not work with class and ids,
    What I do.

    Give the different name to all textarea the CKEditor will work when
    the user submits the form than before submitting form change the name
    values

    like

    $("#submitButton).click(function(){
    $(".input-area additional").each(function(){
    $(this).attr("name","research_projects[]");
    
    })
    $("#form").submit();
    })
    

    I hope this idea will work for you.
    Thanks

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search