Home > Blockchain >  How to add ckeditor for multiple textarea with same name
How to add ckeditor for multiple textarea with same name

Time:10-26

<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.

CodePudding user response:

Give them different IDs and do

document.querySelectorAll("[name^=research_projects]")
  .forEach(elem => CKEDITOR.replace(elem.id));

CodePudding user response:

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

  • Related