首页 > 解决方案 > 将数据库中的动态项目中的所见即所得编辑器显示为类

问题描述

我正在开发报价模块,我可以在其中添加单个或 n 个行项目。名称、描述、价格等行项目详细信息来自项目主数据。我正在使用 jquery 从数据库中添加多个项目。

对于项目描述,我正在尝试使用 CKEditor,它只适用于第一个项目,而不是另一个。

$(".delete").on('click', function() {
  $('.case:checkbox:checked').parents("tr").remove();
  $('.check_all').prop("checked", false);
  check();
});
var i = $('table tr').length - 1;
$(".addmore").on('click', function() {
      count = $('table tr').length - 1;
      var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control' type='text' id='productname_" + i + "' name='productname[]'/></td><input class='form-control' type='hidden' id='productcode_" + i + "' name='productcode[]'/> <td><textarea class='form-control ckeditor' id='description_" + i + "' name='description[]' ></textarea></td><td><input class='form-control price' type='text' id='price_" + i + "' name='price[]'/></td>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table table-bordered">
  <th><input class='check_all' type='checkbox' onclick="select_all()" />
  </th>
  <th>Name</th>
  <th>Description</th>
  <th>Price</th>
  </tr>

  <tr>
    <td><input type='checkbox' class='case' /></td>
    <input type="text" class="form-control" id="productname_1" name="productname[]"></td>
    <input type="hidden" class="form-control" id="productcode_1" name="productcode[]">
    <td><textarea class="form-control ckeditor" id="description_1" name="description[]"></textarea></td>
    <td><input type="text" class="form-control price" id="price_1" name="price[]"></td>
    <td><button type="button" class='btn btn-danger delete'>-</button></td>
    <td><button type="button" class='btn btn-success addmore'>+ </button></td>
  </tr>
</table>

如何为所有行项目显示 CKEditor?

标签: phpjqueryckeditor

解决方案


推荐阅读